Yes they are.

They are a kludge that came about because C++ doesn’t implement object 
behaviour properly.

Try this: http://www.google.com/search?hl=en&q=Singleton%2Bevil


You have not said what about NSFileManager is a great example of the singleton 
pattern.


Of course class methods have their purposes: lots of them!
Normally, not even a class method is allowed to break encapsulation.  What I 
think you mean is that a class method sets class properties that all instances 
of that class refer to..


Of course, class methods aren’t a replacement for the singleton pattern: the 
singleton pattern is a fix for inadequately designed languages.


Karl



On 02/08/2011, at 2:02 PM, Kyle Sluder wrote:

> On Mon, Aug 1, 2011 at 7:14 PM, Karl Goiser <[email protected]> wrote:
>> Wow, class methods finally get the tick of approval!  Only 30+ years after 
>> being specified in the Smalltalk standard..
>> 
>> 
>> Forget about singletons: they are just a workaround for not having class 
>> methods/variables.
> 
> No, they're not. I mentioned the NSFileManager example above; that was
> a great example of how the singleton pattern is more flexible than
> using class methods for the same task.
> 
> Class methods have their purpose. Cocoa and Cocoa Touch use them to
> great effect in places like +[UIView setAnimationsEnabled:], where the
> method logically applies to instances of that class. They help
> maintain encapsulation, since they are defined inside the class and
> therefore, following typical good design principles, are allowed to
> peek behind the public veil of instances.
> 
> But class methods aren't a replacement for the singleton pattern. Even
> if we had class storage (which in practice would be no different from
> static global variables except for scope), class methods would still
> be appropriate for a different set of tasks.
> 
> I wouldn't hold my breath waiting for Apple or anyone else to drop the
> singleton pattern and adopt class methods.
> 
> --Kyle Sluder


_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to