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 18, 2012

SOPA - Democracy vs Capitalism

This could be a possible test of the role of Democracy in Capitalism. Whether the people protesting against SOPA or Hollywood et.al sponsored bill, triumph?

I support artist's copyright, but don't support excessive governance. It will just be abused and it will intervene with freedom to share things. Why is internet any different from letting people borrow CD/DVD/BD  books or other copy righted material offline? Isn't this another ploy to make people pay even more than they already do. I think copyrighted material should be freely available after it has lived its glory days. Something, like brand vs generic drugs. Just put a label - "Free after 1yr". Just a suggestion!

But I am certainly against excessive governance/rules, it stifles growth. Fear can never lead us in the right direction. Do we want responsible people or opportunistic thugs?

Wednesday, January 11, 2012

Subversion Notes

1. Sharing library files among projects:
I discovered a nice way of managing the SVN repository where the library files need not be duplicated for every project. I started a bare bone project with the lib files and imported them into the trunk. Now any project that reuses these library files, only has to branch of this trunk and add its own files. Thus, the lib files remain just in the trunk and need not be checked in for every project that uses the files.
e.g.

ext-4.0 only exists in the trunk, a virtual copy exists in braches.

Next, I will explore svn:externals. Supposedly takes care of this shared files/project issues.

I am using svn 1.7.2 installed with cygwin/windows xp and Tortoise. Note: Apparently tortoise takes over the repository and svn command line seems to fail.

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.