• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Objective-C basics - (Why NSNumber conforms to NSCopying protocol)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Objective-C basics - (Why NSNumber conforms to NSCopying protocol)


  • Subject: Re: Objective-C basics - (Why NSNumber conforms to NSCopying protocol)
  • From: email@hidden
  • Date: Fri, 12 Aug 2016 11:38:10 +0900


> On Aug 12, 2016, at 11:20 AM, Steve Sisak <email@hidden> 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 (email@hidden)

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:

This email sent to email@hidden


References: 
 >Objective-C basics - (Why NSNumber conforms to NSCopying protocol) (From: Sasikumar JP <email@hidden>)
 >Re: Objective-C basics - (Why NSNumber conforms to NSCopying protocol) (From: Steve Sisak <email@hidden>)
 >Re: Objective-C basics - (Why NSNumber conforms to NSCopying protocol) (From: email@hidden)
 >Re: Objective-C basics - (Why NSNumber conforms to NSCopying protocol) (From: Steve Sisak <email@hidden>)

  • Prev by Date: Re: Objective-C basics - (Why NSNumber conforms to NSCopying protocol)
  • Next by Date: Re: awakeFromFetch behaviour change in 10.12?
  • Previous by thread: Re: Objective-C basics - (Why NSNumber conforms to NSCopying protocol)
  • Next by thread: Re: Objective-C basics - (Why NSNumber conforms to NSCopying protocol)
  • Index(es):
    • Date
    • Thread