All Questions
7 questions
9
votes
2
answers
1k
views
Should function names describe their parameter types?
If you wish to perform the same action using different parameters, you can either make differently named functions:
public Apple findAppleById(long id){
return repo.findById(id);
}
public Apple ...
2
votes
5
answers
1k
views
What should a constructor contain?
What should a constructor contain?
In both cases, all three arguments are needed for the class to work.
Which approach is better and why?
1)
class Language {
LanguageRepository ...
45
votes
6
answers
14k
views
Is it better to check `c >= '0'` or `c >= 48`?
After a discussion with some my colleagues, I've a 'philosophical' question about how treat the char data type in Java, following the best practices.
Suppose a simple scenario (obviously this is only ...
1
vote
2
answers
7k
views
guideline on void methods that do not throw exceptions
In our codebase I saw a method that is similar to following:
public void doSomething() {
try {
...
} catch (Exception e) {
...
//log something
...
}
}
The ...
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'...
3
votes
3
answers
6k
views
articles in variable names and hard-coding strings
re-edited by author: no this is not 2 questions. This is one question about code review questions containing two separate points. Please do not edit my question.
For naming variables, the two sides ...
3
votes
2
answers
3k
views
Is repeating links to the same class in a single javadoc comment a bad practice?
I'm currently writing an API and its documentation. For example I have something like this:
public interface Event {
}
public interface Process {
}
public interface EventProcessor {
/**
* ...