> On Aug 12, 2016, at 11:20 AM, Steve Sisak <sgs-li...@codewell.com> wrote:
> 
> Actually, to be pedantic, class cluster is an implementation detail ― was 
> trying to impedance match to OP’s experience level.
> 
> Was speaking purely in terms of public interfaces (since he’s a consumer 
> rather than implementor)
Politely disagreeing. 
I think sub classing is implementation detail as well. 
Class clusters are a bit more to learn, and hard to do well, but for this, it's 
really one right approach proven out by the frameworks and shouldn't be 
avoided. 
They should be introduced so as to show the right path early. That may mean 
saying "I have some learning to do." But it's best to say that and understand 
at least early on there's not a shortcut to learning some things. 

There is one other good approach here depending on class details, and it's a 
good one to also learn to use. 
The design pattern of composition. 

When the real mutable or immutable aspect of a class can be expressed and 
implemented by composing a simple class that has members that are existing 
mutable or immutable classes (usually collections like NSArray or NSDictionary)
then it's often the better choice. Less code less room for error and an 
interface that can work well with existing APIs. Also it can be a good 
opportunity to become familiar with the framework classes by wrapping calls to 
them in identical calls to the new composed class. 
It can be a little boilerplate but removes a lot of decision making that might 
be unfortunate later. 
Performance might later on suggest something more intense like a class cluster. 


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to