Showing posts with label Java Coding Standards. Show all posts
Showing posts with label Java Coding Standards. Show all posts

Thursday, January 19, 2012

Java Lessons [3]


3. Hibernate:
People have been forever zealous about jumping into new technologies, but still hanging on to obsolete ideas. Just noticed a code written for Hibernate, where HQL was formed appending several HQLs & then the parameters as well. I thought we were done with this, having identified security issues like SQL injections & the complete failure in utilizing any caching mechanism offered by Hibernate or event the database.
Use Criteria to handle these dynamic queries, at least it will be clean and secure. And Hibernate can even cache these internally, if not by the DB.

Java Lessons [2]


2. Program Flow: 
Noticed another archaic coding style, apparently when there were no methods, where a single call had a ton of if..else.. handling the same condition. Why not branch off at the first if..else..?
This should be obvious by now, but isn't.

Wednesday, January 11, 2012

Java Lessons

1. Comments vs Naming Conventions:
Method names could be indicative of the operation but not a substitute for comments. There is perennial debate on whether we need java doc - comments vs choosing the succinct approach of choosing the right naming convention and yet I have increasingly found some archaic code that tries to use a method name to contain the entire description which could have been a comment.