Re: [Yact-dev] Null object
Status: Pre-Alpha
Brought to you by:
basic
|
From: Marius S. <ma...@fi...> - 2000-04-13 03:14:50
|
At 09:44 PM 4/12/00 +0200, Daniel Brahneborg wrote: >On Mon, Mar 13, 2000 at 08:54:22PM -0800, Marius Sundbakken wrote: Gee... my original post is almost one month old... :-) > > I think we should add a YNullable interface (or similar): > > [..] > > Let's get rid of as many "if pointer is not null" statements as > > possible. > >Well, there aren't that many of those there, actually. Maybe not now. > > I think this will make Yact a lot more stable (the risk of > > coredumping is greatly reduced) and code-flow in general will be much > > cleaner, prettier, and easier to read. No more of those annoying null > > pointer if's, and just go ahead and access the object directly. > >I'm not so sure about that. I kind of like core dumps, because they let >you know very quickly when something is wrong with the program. If some >method gets a null pointer when it shouldn't, the fix is to get rid of >that null pointer, not add a "if (!p) return". Now, that's why you have assert. Put assertions in and let the program crash when compiled in debug mode. However, when "release mode" is on, the nullable stuff comes into play. Don't crash the program for the user! >Sometimes null objects are ok though, and when that situation comes up, >I'll have no problem introducing YNull(able). I don't see much use for >it right now, though. Do you (apart from that bug below)? Well, again, maybe not so much now, but it fell into my mind and I quickly posted it to the list so that we won't forget :-) But I still stand by it. Getting rid of those 'if not null' statements makes the code nicer, the flow simpler, and the program more stable. Stable is the word, not necessarily correct. But at least stable. - Marius |