All Questions
Tagged with exceptions null
12 questions
1
vote
5
answers
2k
views
Is this an anti pattern or misusing the interface default method?
Instead of checking the null and throwing exception each time we call findByOrderNumber method, I came up with this pattern by taking advantage of a default method, are there any patterns misused here ...
1
vote
2
answers
2k
views
Is it beneficial to throw a caught IOException as an UncheckedIOException in order to prevent NullPointerException?
Not using UncheckedIOException, NullPointerException possible
public void callerMethod() {
Object result = ioMethod();
// call instance method of result
}
public Object ioMethod() {
...
-1
votes
1
answer
338
views
Null Object and Exceptions
Do Special Case or Null Object design patterns still provide value when application behavior, not just object behavior has to change?
I was tasked with revisiting an old application and refactoring ...
2
votes
3
answers
2k
views
Benefit of throwing exceptions for null parameters
The codebase I work with has a certain pattern prevalent in all public methods, which goes like this:
public void UpdateUser(User userArg)
{
Framework.NullCheck(userArg);
var user = userDb....
4
votes
3
answers
3k
views
A very basic question about whether I should check for null and throw NPE? [duplicate]
Consider the below method-
public void operationOnList(List<String> list) {
list.add(1);
}
It is obvious that if list is null this method will throw a NullPointerException.
My question is ...
2
votes
7
answers
6k
views
Throwing an exception when a method does not complete or implement a work around? [duplicate]
I have been studying this subject quite a bit, and I am unsure of what's the best way. I still have a lot to go trough (books, blogs, stack exchange, etc), but I simply can't find a consensus.
...
2
votes
3
answers
177
views
Avoiding null in a controller
I'm trying to work through how to write this code.
def get(params):
""" Fetch a user's details, or 404 """
user = User.fetch_by_id(params['id'])
if not user:
abort(404)
# ...
46
votes
8
answers
126k
views
Why doesn't "object reference not set to an instance of an object" tell us which object?
We're launching a system, and we sometimes get the famous exception NullReferenceException with the message Object reference not set to an instance of an object.
However, in a method where we have ...
4
votes
2
answers
399
views
Nulls in every type and checked exceptions in Java?
I know that null being added to every type in Java is a source of much frustration regarding the language's type system. At the same time I generally hear complaining about checked exceptions - that ...
11
votes
10
answers
2k
views
Should security restrictions cause a service to return null or throw an exception? [closed]
I'm in a bit of a disagreement with a more experienced developer on this issue, and wondering what others think about it; our environment is Java, EJB 3, services, etc.
The code I wrote calls a ...
22
votes
13
answers
4k
views
Why are null references shunned while throwing exceptions is considered okay?
I don't quite understand the consistent bashing of null references by some programming language folks. What's so bad about them? If I request read access to a file that doesn't exist then I'm ...
181
votes
22
answers
59k
views
Are null references really a bad thing?
I've heard it said that the inclusion of null references in programming languages is the "billion dollar mistake". But why? Sure, they can cause NullReferenceExceptions, but so what? Any element of ...