Pages

May 18, 2010

I Have Found The Holy Grails

Lately I have been doing a lot more web and UI development than I normally do. I generally do my best to stay away from anything that interfaces with an actual human, but sometimes you have no other choice.  During this work I have touched a few modules developed with Struts 1, some with the old school Java code inside of  JSP scriptlets, and some using Ext JS with Java servlets serving up JSON data.  I didn't like any of them, so once I finished my tasks I set out to do some research on web development frameworks and have come to the conclusion that if I have my choice of frameworks to use, I would use Grails.

Grails just seems so straight forward to me. In one night I made it through the Grails User Guide, and was able to get a small app up and running.  I have more learning to do with Grails, but I think we are going to become longtime friends.

With that in mind, I think it might be useful to actually do some posts on the various components of Grails. Would anyone be interested in that? Right now I am thinking something along the lines of a series of posts where in the end a full Grails app will have been built.

March 20, 2010

Where Are My Configuration Files???

I recently was tasked to migrate an application that was hosted in a Windows environment to a Linux environment.  It is a Java/JEE web application so I initially thought it would be a quick task.  I installed my JDK and JBoss Application Server on the Linux box and then deployed the WAR file. I pulled up my browser to hit the app and got nothing but stack traces… Not what I expected.

So I did the obvious thing and looked through the logs and found that some configuration files were missing. No problem, except the file names were all hard coded to locations on the Windows C: drive. This is where a big problem lies as there is no C: drive on Linux boxes. Initially, I thought the best solution would be to just use System.getProperty() to get the current OS and use a different path based on what as returned, but the more I thought about it, the more naive that solution appeared to be. It would add more if/else branches in the code and would require future changes if the decision was ever made to move to a different OS. So I went back to the drawing board, and eventually the most obvious and simple solution came to me. USE AND ENVIRONMENT VARIABLE FOR THE CONFIGURATION FILE DIRECTORY!!!

I don’t know why I didn’t think of it sooner. By using an environment variable to store the configuration file directory I can simplify the code and will never have to update it for future OS environments. In the meantime, to run the app all that will need to be done to ensure the app gets its configuration is just add another environment variable. I am pleased with this.

January 21, 2010

The Sun Sets

So it looks like the Oracle acquisition is finally going to be approved by the EC so the nerd shop that is Sun will be no more. Everyone is kind of waiting to see what will happen with Java and MySQL, but no one really has any idea what will happen. All of this really makes me wish that Java had truly been open sourced because there is no telling what will happen with the JDK.  As for MySQL, I see no way that Oracle doesn’t kill it.  Hopefully Monty’s branch of MySQL, MariaDB, is strong enough to support the current MySQL community if that happens.  I just wish Sun had found a way to stay afloat because that truly would have been the better option in this scenario.

January 3, 2010

Resolutions

I have done a lot of thinking the past few days and decided I wanted to share a few New Year Resolutions.

  1. Make blogging a priority. I have so many ideas that pop into my head, but I never take the time to think them through and write them down. I want to actually start doing that because I feel I have a lot to offer to the community.
  2. Be more innovative. This past year I let myself fall into a pattern where I always do the same thing when I am coming up with solutions for projects. I need to challenge myself to step out of my comfort zone.
  3. Finally learn Spring and Hibernate. Like many people, I am in a situation where I am maintaining current and legacy apps that use some older technologies. This means I am basically making fixes to Struts/EJB apps that used to be the standard. The world has moved on to Spring and Hibernate and I have been too lazy follow suit. That will change this year.
  4. Become more active in local user groups. Last year I started to periodically attend the Java and .NET user group meetings in my area. I enjoyed them, but I didn’t actively participate in the meetings and as soon as I got busy with work I stopped going. I’d like to start attending more and get to the point where I could actually present something at a meeting.

I know these may be simple, but I figure if I start small I might be able to be an overachiever this year. I really want to accomplish these because I know these will help me become a much better software engineer.

December 9, 2009

A Float is NOT a Currency

Do not use floats when representing currency.This is just asking for trouble.

Anytime you have to deal with floating point representations you can always get unpredictable results. I cannot count the number of times I have seen the "phantom penny" situations where balances are a penny off and you end up spending half a day with your accountant hat on trying to find where the penny went. You look and look and then you realize that somewhere in the code someone used a float inside the calculation. You change the variable type and your penny "magically" appears.

There are many alternatives in the modern programming languages for representing currency and they should be used. If those are not available, you can always go old school and use the int primitive type to represent currency.