Posts

Showing posts from February, 2015

Java Best Practices

Use meaning full names The name must specify where the parameter is used for. For example if you want to store the elapsed time in days, name it that way. Of course don't make it all too long, the more you need to read, the slower you will have read it. good bad Int elapsedTimeInDays Int n; // elapsed time in days int elapsedTime; // in days   int elapsedNumberOfDaysFromStarttime void postPayment( ) { ... } void do(){...} Use pronounceable and searchable names. Unpronounceable names make it difficult to search through your code and find errors Date generationTimestamp; Date genymdhms; // generate year month day hour minute second Date randTime; // sounds like ran time Use names for constant numbers. When you need to search for a certain pattern, these words help you telling where a number is u...