All Questions
4 questions
1
vote
5
answers
210
views
End method in normal flow versus exception flow
Consider the two following examples:
public Something fetchSomething(String key) {
if(somethingsMap.containsKey(key)) {
return somethingsMap.get(key);
}
throw new ...
2
votes
3
answers
764
views
Why do assertions in Java need to get enabled?
I really like the concept of assertions in Java in the way how to use them. It's much easier than to write an if and then throw an Exception/Error.
But the thing I don't understand is, why do they ...
0
votes
1
answer
123
views
Return values and exceptions [closed]
I wrote simple function that returns a string depending on which condition is TRUE. Here is my code:
private String getMyString() {
if(!mStrigMember.isEmpty()) {
return mStrigMember;
}...
34
votes
8
answers
15k
views
Is throwing an exception an anti-pattern here?
I just had a discussion over a design choice after a code review. I wonder what your opinions are.
There's this Preferences class, which is a bucket for key-value pairs. Null values are legal (that'...