piaoyongren / core-plot

Automatically exported from code.google.com/p/core-plot
0 stars 0 forks source link

Struct-like classes should have immutable variants #232

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Classes like CPTextStyle and CPLineStyle are struct-like in that they simply 
act as storage vessels for attributes. The fact that these classes are mutable 
complicates the design of Core Plot, because it requires that the framework 
monitor to changes to any properties and update appropriately.

A better, more Cocoa-like solution would be to introduce mutable subclasses, 
and make these classes immutable. 

A model for this would be the NSURLRequest class. In practice, you rarely 
create a NSURLRequest directly, but create a NSMutableURLRequest and upcast it.

The same could be done in CP. Properties in the framework would be immutable, 
simplifying framework design. Users of the framework would create mutable 
objects, setup as required, and then pass them to the framework where the 
compiler would ensure they were not modified.

Original issue reported on code.google.com by drewmcco...@mac.com on 12 Dec 2010 at 7:14

GoogleCodeExporter commented 8 years ago
This has now been implemented for CPLineStyle and CPTextStyle. CPFill is 
already immutable.

Original comment by drewmcco...@mac.com on 13 Dec 2010 at 11:25