Saturday, October 3, 2009 [Tweets] [Favorites]

Care and Feeding of Singletons

Mike Ash:

Programmer safety is, in my opinion, counterproductive. Apple’s approach, of building a singleton which can’t be destroyed by accident and which intercepts attempts to allocate a second instance, covers up errors rather than fixing them. It’s much better to trap and eliminate the bad code rather than render it harmless. For example, instead of overriding release to do nothing, override dealloc to log an error and abort the program.

Fail fast!

Comments

Stay up-to-date by subscribing to the Comments RSS Feed for this post.

Leave a Comment