- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
I ran over a raccoon in a rental car in Florida once, while I was driving through Massachusetts.
Admin
Admin
The most generic program is AI. But it would refuse to work for such boss ;) .
Admin
sigh
I can't believe a throwaway comment I made about defensive programming against null pointers would spark a Null pointer exception handling holy war.
But you got it in a nutshell.
I recently worked with a third party application framework, closed source, that regularly returns null as a valid value.
It even returned null for a method that returns a collection if it was unable to fill said collection. [I suddenly hear a million Java devs scream out in anguish]
Not being aware of what type the usedField array is and who fills it, I would naturally code defensively against nulls. At least until I knew more about the codebase in this instance.
The "Constant".equals(Variable) idiom is the one I use to prevent (avoid/swallow/hide/ignore/whatever) null pointer exceptions from occurring when a variable can validly be a null.
Alternately you could surround the if-else statements with a single if statement to check for null. But this would increase the indentation and I personally think it looks ugly.
Admin
Admin
I did neglect to account for situations where 's' could validly be null - i.e., when we don't have a value (as opposed to the string being empty, which is a different thing). Too much c# coding, I guess. This is certainly a possibility in database apps, however, and the calling code should, in that case, check for null.
In terms of defensive programming... it depends. An assert is appropriate for some applications. For others (gaming comes to mind) one would just have to envision the outcome of returning 'false' if we did accidentally get a null value in the function - is it better or worse? Either action, true or false, it is probably wrong -- we just want to do the least-wrong thing. And again, I'd use an assert here to catch the possibility of bugs during development (but ensure the assert() is no longer in effect in production code).
So... for defensive purposes, yeah, okay. Functionally, one should not call foo(s) unless s is non-null. In certain situations {s} /might/ be null, so the calling code would need to check for that. But, for defensive (and keep in mind, this means less-efficient) code, foo() can also check for this.
Admin
I want to sort the input array lexically by field names because i like order.
This could all be avoided by using fixed array positions like 98 for Subject, 99 for From and 100 for To.
Admin
French?
Admin
nfl sales nfl for sales jersey store Christian Louboutin
Admin
Hi guys!! This is my first website by my self, and i confused that is it good or not made by wordpress or Joomla, i want to choose one 4 me,and give me vsome advice.Thank you! http://www.sportsjerseysshop.com/