On Apr 13, 2008, at 12:40 PM, Alex Curylo wrote:
No, I can personally assure you that exact practice has led me to finding many dozens -- quite possibly several hundreds by now actually -- of 'calling methods of a deleted object' type bugs in C+ + code, particularly game code I port from Windows, which somehow always seems to have been written by semi-literate chimpanzees on crack. And perhaps I am unfair to the chimpanzees here.
As a former game porter, let me offer my condolences here. I know exactly what you mean.
It does seem that class of problem is much less likely to arise with Objective-C object references (I'm still fairly new to this Cocoa thing) but as long as I still work with any C++ objects or raw pointers, I'm going to consider that "set things up so anything accessing this object's memory after I'm done with it promptly causes an access violation" is a valuable habit -- nay, essential practice -- in properly defensive programming. Autoptrs and the like help, but they're not foolproof. Stands to reason that the retain/ [auto]release paradigm isn't completely foolproof either, although it does seem pretty resistant to commonly accepted levels of foolery so far.
The big difference is that in Objective-C, trying to send a message to nil results in a no-op instead of an access violation, so your defensive C++ practice is actually going to tend to mask those same errors in Objective-C and make them harder to track down.
Hope this helps, - Greg _______________________________________________ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]