Showing posts with label Java Development. Show all posts
Showing posts with label Java Development. Show all posts

Saturday, November 3, 2007

Java 6 on OS X

Hey Apple, please be more vocal with your plans for Java. I love my mac and want to continue using it as my main development machine. I don't doubt good things are happening - just would like more (good) buzz out there. I've seen many Java developers be converted to mac (me included - now I own three macs and an iPhone) and then go on to spread the good word.

13949712720901ForOSX

Friday, March 16, 2007

Groovy on OS X and MacPorts

Update Note: This is still the case with Groovy 1.6.x and Leopard the same fix still works.

The default MacPorts install of groovy didn't work out of the box. When I ran groovy from the prompt I got a nasty java.lang.SecurityException.

The problem ended up being that my Java CLASSPATH included classes.jar.

The solution ended up clearing out the CLASSPATH system variable altogether before invoking groovy. You can do this with a command line switch but the easiest way to do it was to edit the startGroovy file (found in the /bin directory of the groovy installation). A fast way to find this is using Spotlight

I simply added CLASSPATH= as the first thing in the file:

...
##
## $Revision: 4298 $
## $Date: 2006-12-04 02:39:45 +0100 (Mo, 04 Dez 2006) $
##

CLASSPATH=

PROGNAME=`basename "$0"`
...

Groovy Process Piping: Follow-up

Thanks to some comments from those a bit more savvy on this topic I'm suggesting the following method from charlesanderson:

p=['sh','-c','ls -l | sort'].execute()
println p.text

This is mostly cross-platform (assuming CygWin) and is nicely succinct.

I like this method over using the Groovy Groosh module as suggested by Yuri Schimke if only because it doesn't require an import:

def f = gsh.find('.', '-name', '*.java', '-ls');
f.pipeTo(lines);

As always there are many ways to skin the same cat.

Thursday, January 25, 2007

Commenting fields/methods

Less comments but more content.

Along with methods, if a field has to be commented, I’ve found it is usually because it is misnamed.

// Counter that keeps track of login attempts private int counter;

Would be better expressed as: private int loginAttemptCounter;

It is funny how this simple DRY concept can keep you on the high road of development. Also important is spell-checking and grammar. While a comment shouldn’t be an English thesis paper it should be professionally written. If English is not your strong point have a buddy on the team review your code for errors. Even the best authors lean heavily on editors (the human proof-reading kind not the text-editing kind).

EZ Project Management

No matter what the chosen process is or how tasks are broken up, every major project I’ve been on has been time blocked:

  1. Management decides the new system should be finished by date X.
  2. The analysts and project manager divide the amount of tasks by the number of iterations available before date X.
  3. For each iteration-task-set you divide it evenly amongst your available developers.
  4. You ask your developers for an estimation on their tasks for each iteration.
  5. They respond by taking the number of assigned tasks, divided by the hours available in the iteration.
  6. Some magic happens (scope reduction, overtime, bring in experts to clean up, implement tasks with TODO: statements)
  7. The project finishes on date X.

I’ve developed this project management process on a single MS excel sheet. I’m making it available for a cost of $1000 per seat with an annual $10K maintenance charge. Of course I can offer consulting services to customize it to your corporation at a $300/hour bill rate. Do you like curly fonts?

Corporate Code Smells

Mostly venting here, how many of these have you seen?

Corporate Code smells:
  1. WSAD - There is a reason it isn’t called WHAPPY
  2. Only javadoc is the eclipse message telling you how to change your default javadoc templates
  3. No interfaces at all or an interface for every class
  4. junit.jar exists in the lib directory but no tests to be found
    • I got this unit test that calls the production database
  5. optimized imports? code formatting? we don’t have time in the project plan for that
  6. Sure we use Spring, but we wrap it with our own classes so we can switch it out later
    • We’ve cached the bean instance returned by Spring to speed things up
  7. We added hibernate because we knew we were going to hit the database
  8. Synchronization? Threads? the container takes care of that
  9. Guys, look at this framework I cranked out last night!
  10. With annotations I was able to expose all my classes as web services, you know, for reuse!