Null means *nothing* or *unknown*, depending on context.

learn more… | top users | synonyms

0
votes
0answers
6 views

Getter within loop returning null after assigning values [migrated]

I've got a slight problem with my program. Simply put, what I do is this: Choose the option to "Add a new Student record". When I try to display the newly added values (First Name, Last Name, ...
7
votes
2answers
107 views

Use different contructors of disposable class

I have a very simple helper class to validate credentials. Sometimes the domain has a value, sometimes not. Depending on this, a different constructor for ...
0
votes
0answers
11 views

Reverse Boolean compund logic with NULLs (Change a complex Filter In condition to a Filter Out condition) [closed]

I've been tripping on this one for awhile. The actual logic is even more complex, but simplifying it this far is sufficent. (For those who care, (which does not include the vendor!), the product ...
2
votes
2answers
33 views

Assign Specific Value If BitField Is True

My colleague created this SQL to handle certain user selections which are based on an on/off bit flag. The goal is to identify those individual bit flags with a specific integer which will be used in ...
11
votes
4answers
769 views

Writing null-safe code to set form values

I will ask my question using the following example: HTML ...
3
votes
1answer
58 views

Correct practice for Python properties that depend on other attributes

When a property is essentially a boolean value for whether or not an attribute exists or is set a certain way, is it more appropriate to create an object that does not list the option attribute in its ...
5
votes
4answers
140 views

NULL-eating / elimination version of fgets() in C

I've come up with the following routine to read data from a file stream, but I don't want any NULLs in the stream to terminate the string early. This function will ...
0
votes
0answers
53 views

Checking a value before assigning it to variable

Throughout my code, I find myself testing if the output of a function is undefined or blank before i use the output. In this case, getQuery checks if the property of an object is either blank or if ...
7
votes
3answers
126 views

Creating check parameter class instead of repetitive null checks

What I'm trying to accomplish is to have a error checking class mostly to check if parameters that are pass null but also data structures within class are not null. So my thought is a clean static ...
7
votes
3answers
115 views

Too many null checks in an XML-to-XML transformation

I'm writing a conversion mechanism in C#. I deserialize a big XML document of one type and return a big XML document of another type (via serialization of another object). While I'm doing the ...
1
vote
1answer
158 views

Null checking in nested getter calls [closed]

I have the following piece of code and I would like to see what different approaches would be to solve that in a more elegant way. The thing is that I don't know whether is better to have the null ...
5
votes
2answers
354 views

Writing a generic performance efficient isEmpty method which can check for null or emptiness

I am writing a utility method which can check for empty and null string, or collection or an object or any general types - ...
2
votes
2answers
46 views

Using Common Table Expression and Outer queries

In following query I'm use both Common Table Expression and Outer queries. Apparently both looks same to me. If I summarize my requirement, I have employees in ...
7
votes
1answer
202 views

Getting matching items in lists based on nullable properties

I'm iterating through two lists to find matching objects. The objects have two string properties, Id1 and Id2 below. If ...
10
votes
1answer
188 views

Organization data class

I believe I have made the following data class quite decently, and I'd like a thorough review on it. The code is built on Java 8 and uses the Builder and Serialization Proxy pattern, it is used to ...
3
votes
1answer
78 views

Should I null coalesce EventArgs?

When I implement events, it usually looks something like this: ...
4
votes
1answer
125 views

Is checking for null redundant while using Contract Annotator from JetBrains?

I'm curious whether checking for null is redundant in this concrete example. ...
7
votes
2answers
148 views

PHP isset over use? Good or bad?

First, I'm in no way an experienced PHP coder. This is my 5th time working with PHP, so if you see anything that can bee improve, please point them out for me. I have the code checking for the ...
4
votes
2answers
187 views

Duplication with nested null checks

How can I improve this code with nested null check statements? ...
6
votes
2answers
107 views

Inventory check with too many else-ifs

I am using if else statements: ...
14
votes
2answers
574 views

Using finally with return statement or not

I was wondering if it is the proper way to always put the return statement of a function with a try-catch clause in the finally ...
1
vote
2answers
33 views

Domain object toString null check

Following advice to "Make good use of toString() for all Domain classes", I made what I thought was the most useful toString ...
6
votes
2answers
190 views

How do I better structure Java code to avoid dereferencing null? [closed]

I have the situation where as long as the user gives valid input, the StringBuilder object will not be null. ...
5
votes
2answers
882 views

Extension method to return a default value for any null value

I'm creating an extension method that can be used on any type. The idea is that if this method is called, it checks if value is null. If null, it needs to return a default instance of the specified ...
-2
votes
2answers
103 views

Refactoring the logic of a return value

In my method I have something like this: ...
1
vote
3answers
256 views

Coding style preference if (aPtr), if (aPtr != NULL), or if (NULL != aPtr) [closed]

I understand that as far as the compiler is concerned, the following lines are equivalent. if (aPtr) {...} if (aPtr != NULL) {...} if (NULL != aPtr) {...} ...
19
votes
4answers
2k views

Just a lowly counter that turned out to be surprisingly complicated

While writing this review, I saw a need for a Counter object similar to Python's. It seemed like it would be easy to write such a class, but it turned out to be ...
7
votes
5answers
624 views

Returning null or what?

I have a C# function like below, and in the else block, the function must return something. I don't know whether returning null is a good practice or not. ...
0
votes
6answers
1k views

Which Java string value is preferred to return: blank or null?

I came across this snippet and am wondering if I should return blank in this case. Which is more practical to return: blank or ...
2
votes
3answers
209 views

Reduce cyclomatic complexity

How can I reduce cyclomatic complexity of validation and refactor it better way? ...
3
votes
3answers
316 views

Return value when the requested variable returns null

I have a method that returns a list from a HTML page: ...
10
votes
2answers
261 views

Nullable<T> Implementation for VB6/VBA

Because I was spoiled with C# and the .NET framework, whenever I have to work with VB6 I feel like something's missing in the language. A little while ago I implemented a ...
1
vote
2answers
86 views

Reducing cyclomatic complexity in a simple string concatenation

I have written the following function that takes an address object and builds a string using the object properties. It will later be used to display a tooltip ...
8
votes
2answers
141 views

Idiomatic Scala try option code block

Basically, this function returns a list of flights for an airline. But if the airline doesn't exist, I want to throw some custom runtime exception. If that airline does exist, I want to return a list ...
7
votes
4answers
8k views

null/undefined checking for checking seats

This looks pretty messy (need to reduce nesting I feel). I need a check an input for a seat, but I can't guarantee it has a value (one may not be chosen for example). If the seats aren't in a certain ...
1
vote
2answers
178 views

A custom Java collection which doesn't support nulls

I am making a GWT application and have to prevent client code from using null values in collections. I found an answer but GWT doesn't support Queue and its ...
1
vote
1answer
659 views

Handling nil: Trying to avoid #try

Yesterday, I introduced a bug into our codebase by calling #titleize on a string that could possibly come in as nil: ...
3
votes
2answers
210 views

Null Object pattern with simple class hierarchy

I have a simple two-class hierarchy to represent U.S. ZIP (12345) and ZIP+4 (12345-1234) codes. To allow clients to allow both types for a field/parameter or restrict it to one type or the other, the ...
4
votes
4answers
681 views

Instantiating if null

I often have static classes which uses the DataContext somehow, and they all make a new DataContext, but often I already have ...
4
votes
4answers
238 views

Simplify Oracle SQL: Treat null date as 'N' and non-null date as 'Y'

This works, but nvl AND case seem redundant. Basically, if null then 'N' else 'Y. CHICKEN_HATCH_DATE is a DATE data type. ...
5
votes
3answers
6k views

Checking for Null before adding into List

Is there any way to refactor this? ...