On 15 Apr 2013, at 00:25, Graham Cox <graham....@bigpond.com> wrote:

> 
> On 14/04/2013, at 2:08 PM, YT <y...@redwoodcontent.com> wrote:
> 
>> My struggle is partially due to my lack of experience in OOP. I just have 
>> not written enough OO code as of yet.  AND I'm very new to Objective-C. 
>> Hence my lack of experience and working knowledge of Objective-C.
>> 
>> extern int gFoobar;
>> 
>> I understand that solution and its working for me right now.
> 
> 
> I understand how tempting it is to go with whatever you can get working, 
> especially when you're new to something.
> 
> But in this case I believe you should resist the temptation and try and gain 
> a little more understanding before you get too far down this road.
> 
> GLOBALS ARE BAD NEWS. That is a pretty good rule and well worth sticking to. 
> If you can get rid of globals (and you always can) then you should avoid 
> them. There is NO problem in application programming that requires a global 
> to solve it. Singletons are a much safer and more predictable means of 
> achieving something that has global scope but prevents the hidden 
> state/parameters problem that globals bring with them.

Wow, I really can't get my head around this one.  You make bold statements like 
"GLOBALS ARE BAD NEWS" (which I 100% agree with), but then follow up with 
effectively "use singletons instead".  Singletons bring with them 95% of the 
problems globals bring.  They still break any attempts at threading, they still 
break any attempts at testing, they still break separation of concerns, and 
they're always avoidable.  So I'd follow up with SINGLETONS ARE BAD NEWS TOO!  
In 95% of cases where you have a singleton, you should almost certainly be 
using dependancy injection instead, or some other method of avoiding it.

Note also – simply using your app delegate as a store for things that aren't 
singletons, but only one of them is pointed at by your app delegate is also 
horrific – you're just substituting one singleton for another.

Thanks

Tom Davie
_______________________________________________

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