[Based on the strong comment below (dated April 7 and 8, 2010) from when I originally posted this question, I took a hard look at what I wrote and asked myself "Huh? What am I really after here?" I decided drastic action was called for: discard the original text, make the question simpler and cleaner, and focus on what I really want to g...
What's the best way of writing robust code so that a variable can be checked for null and blank.
e.g.
string a;
if((a != null) && (a.Length() > 0))
{
//do some thing with a
}
...
I need to serialize some data in a binary format for efficiency (datalog where 10-100MB files are typical), and I'm working out the formatting details. I'm wondering if realistically I need to worry about file corruption / error correction / etc.
What are circumstances where file corruption can happen? Should I be building robustness t...
How does Java handle integer underflows and overflows?
Leading on from that, how would you check/test that this is occurring?
...
Is code that uses the static Object.Equals to check for null more robust than code that uses the == operator or regular Object.Equals? Aren't the latter two vulnerable to being overridden in such a way that checking for null doesn't work as expected (e.g. returning false when the compared value is null)?
In other words, is this:
if (Eq...
Hello everyone,
when implementing/using methods that return or work with instances of objects, what is the most elegant approach to check the function parameters ?
Method to call:
someType GetSomething(object x)
{
if (x == null) {
return;
}
//
// Code...
//
}
or better:
someType GetSomething(object x)
{...