The Daily Static
  The Daily Static
UF Archives
Register
UF Membership
Ad Free Site
Postcards
Community

Geekfinder
UFie Gear
Advertise on UF

Forum Rules
& FAQ


Username

Password


Create a New Account

 
 

Back to UserFriendly Strip Comments Index

To null or not to null? by Khaar2009-01-29 02:19:43
  NULL should get the job done by Bedda 2009-01-29 04:10:51
I can't imagine any scenario where NULL should be a accepted value but if it is so in your case i would go for something like B.

Generate an object which has your numeric variable and a bool.
Make sure the numeric variable is protected and create simple Set and get methods for it. They you still need to check the boolean but at least you can be sure that noone forgets to set the boolean when the numeric variable is set.

In my opinion
if (variable == NULL) blablabla;

is more "eyefriendly" than

variable.set(blabla)
variable.get(blabla)
[ Reply ]

 

[Todays Cartoon Discussion] [News Index]

Come get yer ARS (Account Registration System) Source Code here!
All images, characters, content and text are copyrighted and trademarks of J.D. Frazer except where other ownership applies. Don't do bad things, we have lawyers.
UserFriendly.Org and its operators are not liable for comments or content posted by its visitors, and will cheerfully assist the lawful authorities in hunting down script-kiddies, spammers and other net scum. And if you're really bad, we'll call your mom. (We're not kidding, we've done it before.)