Tagged Questions
45
votes
9answers
2k views
When does “proper” programming no longer matter?
I've been building an android game in my spare time. It's using the libgdx library so quite a bit of the heavy lifting is done for me.
While developing, I carelessly selected datatypes for some ...
25
votes
5answers
1k views
Is use of finally clause for doing work after return bad style/dangerous?
As part of writing an Iterator, I found myself writing the following piece of code (stripping error handling)
public T next() {
try {
return next;
} finally {
next = ...
16
votes
9answers
2k views
Is there any reason to use “plain old data” classes?
In legacy code I occasionally see classes that are nothing but wrappers for data. something like:
class Bottle {
int height;
int diameter;
Cap capType;
getters/setters, maybe a ...
13
votes
2answers
597 views
What is the best approach for inline code comments?
We are doing some refactoring to a 20 years old legacy codebase, and I'm having a discussion with my colleague about the comments format in the code (plsql, java).
There is no a default format for ...
8
votes
5answers
873 views
Is it bad coding practice to create something in a get if it does not exist?
So I have a webservice that has something like a getAccount where it would return an identifier to the account if it got it, else throw an exception. The client will always want to create an account ...
8
votes
11answers
3k views
Why is using System.out.println() so bad? [closed]
Of course, it is very good use to use a logging framework for the error messages or warnings. But sometimes I use System.out.println() if I want to try something new in a short time.
Is it really so ...
5
votes
6answers
267 views
How to keep a project easy to understand and intutive?
I am working on this project, which will soon contain loads of packages, projects etc. (Java). So, from the start I need to keep track of the high level package and class structure, monitor which ...
5
votes
5answers
578 views
Prefer class members or passing arguments between internal methods?
Suppose within the private portion of a class there is a value which is utilized by multiple private methods. Do people prefer having this defined as a member variable for the class or passing it as ...
4
votes
3answers
215 views
HTML code in Java class
A conceptual question, I tried to google but couldn't find any definitive answers, so here it goes:
Is it a good practice to write Java methods to return HTML strings that will be returned to the ...
4
votes
1answer
208 views
Distinguishing repetitive code with the same implementation
Given this sample code
import java.util.ArrayList;
import blackjack.model.items.Card;
public class BlackJackPlayer extends Player {
private double bet;
private Hand hand01 = new Hand();
...
4
votes
1answer
124 views
Is there a modern replacement for a mutation testing tool like Jester for Java?
“Why just think your tests are good when you can know for sure?
Sometimes Jester tells me my tests are airtight, but sometimes the
changes it finds come as a bolt out of the blue. Highly ...
3
votes
1answer
2k views
What is the best way to comment a deprecated class in Java?
I would like to know the best way to add a comment to identify a deprecated class in Java. Should I remove the previous comment added to the top of the class that helps another programmer to know what ...
3
votes
1answer
225 views
Why Doesn't Java Allow Default Parameters/Arguments [closed]
Basically something like
public void jumpToRoom(String roomName = Rooms.DEFAULT_ROOM)
would be convenient.
Many languages nowadays seem to support it (Ruby, PHP, even C#).
What is Java's ...
2
votes
3answers
248 views
in doubt of using code generators
I am now entering the world of java ee 6. And I am supposed to used different technologies like jsf, jpa, different kinds of beans and all that stuff.
I am learning using the netbeans IDE, which is, ...
1
vote
6answers
413 views
Structuring multi-threaded programs
Are there any canonical sources for learning how to structure multi-threaded programs? Even with all the concurrency utility classes that Java provides I'm having a hard time properly structuring ...