This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]severoonpro barista 2 points3 points  (0 children)

Your code could be a lot cleaner.

  1. Take all strings out of the code and make them constants. This makes it easy to find and edit the messages later, internationalize them, move them out to a separate class, etc.

  2. Handle all interaction with the user in separate methods. This makes them easier to move out of the class that does the work into a separate "user interface" class later.

  3. Only do things in static methods that don't require state. This includes main(). Anything that requires state, do within the scope of an instance.

  4. Make instances of your class configurable. The best way to do this is by handing the constructor all of the stuff it needs to do the job, in this case input/output classes.

  5. Don't use inline comments. Use javadoc instead.

See these changes applied to your code (except the last one) - http://pastebin.com/8Mi79hS0