• 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: NEWBIE: Why use protocols?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NEWBIE: Why use protocols?


  • Subject: Re: NEWBIE: Why use protocols?
  • From: Ondra Cada <email@hidden>
  • Date: Wed, 18 May 2005 21:03:49 +0200

Ben,

On 18.5.2005, at 20:32, Ben D. Jones wrote:

The reason I ask is that I'm actually starting on a very large project (my first big project) in Cocoa. Having done large projects in C I'm not a newbie to programming, just Cocoa. So in what cases (example of use) would it be needed or proper to use protocols?

Never really needed (but for a few very specific cases like if you want to supply method signatures to limit the round trips with Distributed Objects).


Proper... well, that's a question which, I guess, different programmers would answer in different ways.

Anyway: if you very strongly feel a need to formalise a set of methods, which make sense only as a complete set (i.e., the very opposite from the delegate methods!), and which may be implemented by a number of unrelated classes, consider formal protocols.

Though, be wary that there are some gotchas. As the Apple documentation says: "Formal protocols have their limitations. If the list of methods declared in a protocol grows over time, adopters of the protocol would become non-conforming. So formal protocols in Cocoa are used for sets of methods that are stable, such as NSCopying and NSCoding. If you anticipate growth in the set of protocols methods, declare informal protocols instead of formal protocols."

Myself, I've been declaring *heaps* of formal protocols fifteen-odd years age when I started learning ObjC. Today, I hardly ever use them :)
---
Ondra Čada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc



_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >NEWBIE: Why use protocols? (From: "Ben D. Jones" <email@hidden>)
 >Re: NEWBIE: Why use protocols? (From: Cameron Hayne <email@hidden>)
 >Re: NEWBIE: Why use protocols? (From: Daniel Jalkut <email@hidden>)
 >Re: NEWBIE: Why use protocols? (From: Ondra Cada <email@hidden>)
 >Re: NEWBIE: Why use protocols? (From: "Ben D. Jones" <email@hidden>)

  • Prev by Date: Re: Spotlight Plugin Woes
  • Next by Date: Re: NEWBIE: Why use protocols?
  • Previous by thread: Re: NEWBIE: Why use protocols?
  • Next by thread: Re: NEWBIE: Why use protocols?
  • Index(es):
    • Date
    • Thread