Focusing on Readable Code

With the information given, it should not be too difficult to create new programs in the language of choice. However, there is a serious matter that I wish to address and that is making well-formed and readable code. On a regular basis, I often see code that is hard to read due to its structure. Also, I often see methods or constructors that are needlessly large. With that in mind, here are a few tips to help make code more readable and well formed.

1. Avoid having methods that are larger than your own head when possible - I know that this seems like an odd prospect, but most methods can be kept to usually around eight to twelve lines of code unless it involves making a graphical user interface such as using the SwingUI in Java. (Even then, it still is possible to minimize the size of most methods using various tactics.)

2. Use documentation to better elaborate on what methods perform - All too often I see a painful lack of documentation on programs, even in advanced programming classes. There isn't any reason to not document code, especially when working in a group project. This will allow for a quick summary of what each part of the program does and assists in reading the code. For that matter, the recommended Java Coding Conventions (which can be read at gives some great guidelines for effective documentation.

3. DRY: Don't Repeat Yourself - On a regular basis, I see the same set of commands being done multiple times. This can be averted by using a method to launch these set of commands based on an input and have it return the end result. This will save time and will make a person's code look much more slick.

4. Focus on making methods private when possible - I know this may sound strange, but there are several legitimate reasons for this tip. When a method is not used outside of the class, there is no reason for it to be public and having it public could actually cause some problems should another class attempt to use it in a manner that it shouldn't be used.

5. Minimize the amount of getter/accessor methods - There are often many people who automatically make getter/accessor methods for all of the values held by an object. Before making a getter method, always ask if the returned value will be used in a meaningful manner as the reality is that in many cases they aren't.

With these tips, I consider what feel to be the initial edition of basic programming concepts to be complete. This does not mean though that this is subject to revision. In fact, there is a chance that I may start a new series to continue from where this one has left off depending on the feedback of others.