[haiku-commits] Re: r38135 - haiku/trunk/src/preferences/print

  • From: Stephan Assmus <superstippi@xxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 16 Aug 2010 21:41:02 +0200

Am 16.08.2010 21:22, schrieb Michael Pfeiffer:

Am 16.08.2010 um 20:40 schrieb Urias McCullough:

On Mon, Aug 16, 2010 at 9:52 AM, Michael Pfeiffer
<michael.w.pfeiffer@xxxxxxxxx>  wrote:
And doing an assert would be a bit silly. If the only way to avoid a crash
is to crash before it, why bother adding code for that ?

Using an assertion ensures the crash to happen near to cause of the problem. I 
wouldn't call that silly.

Since it's likely going to crash 3 lines later when its dereferenced
anyway, so i'm not sure it's going to matter so much in this case.

There is also a chance that it will crash somewhere else.
As a professional programmer only 100% probability should count.

In my initial reply I asked how this kind of changes should be treated in 
general.
 From the mails so far my impression is, that it is OK to have unsafe code in 
Haiku.
Anyway, I hope I have made my point clear.

I prefer robust code which potentially survives changes by another developer. So in this case, I prefer dynamic_cast if there could be other kinds of items in the list. Or using a type-safe list implementation. However, the original code was not safe, since it didn't check for a NULL pointer returned from dynamic_cast, which defeats the purpose of being robust by using dynamic_cast in the first place. For what the code does right now, it should instead use a type-safe list. This should even be the case for when there could be different kinds of objects in the list, only then the list should be typed to the common base class.

If it isn't clear from the above, we prefer robust code in Haiku.

Best regards,
-Stephan

Other related posts: