Pages

Thursday, September 17, 2009

Is Spring Framework becoming a configuration nightmare?

I had a crappy day dealing with Spring Framework 3.0 M4. I've been using Spring since 2004 and I've been a big fan of its use. Lately however, I've become concerned that Spring Framework is turning into another EJB, a configuration monster. I've been using Spring 3.0 M1 for a while now and recently upgraded to M4 to get access to some new Spring MVC annotations, @RequestBody and @ResponseBody. These annotations allow you to bind directly to the request body and response body, respectively. They're very helpful if you are using Spring MVC for ReSTful web services. They seemed relatively innocuous, but after some time with them, they are much more complicated to configure than one might expect from Spring. Still don't have a working solution with these new annotations. Part of it is the documentation isn't where it needs to be, but that will hopefully be remedied by the time 3.0 is GA. In the meantime, I'm stuck on the damn configuration of view resolvers, mapping adapters, and what not. Configuration kills! I've had the chance to work on Grails and I must say, I am very much longing for another opportunity to work on that platform. I realize that Grails uses Spring, but Grails also keeps Spring away from, behind the covers for the most part, so I can build solutions for my client instead of muddling through configuration acrobatics.

Tuesday, September 15, 2009

Keeping traceroute/tracepath by my side these days

Ugh! All sorts of networking issues lately at work. Each environment is set up differently from a networking standpoint. Makes promoting code a pain in the butt. I've been giving traceroute and tracepath both a workout these past couple of days. Who says learning Unix utilities is a waste of time in this day and age of graphical desktops and networking utilities. One tip from today: Make sure you specify the port that you want to route to in the traceroute/tracepath invocation. In our case it did make a difference ;-)

Monday, September 07, 2009

Snow Leopard ships with Subversion 1.6.5 support

Just upgraded to Versions 1.0.5 and noticed that Snow Leopard ships with Subversion 1.6.5 libraries and command line tools. Very cool. I'm assuming Xcode 3.2 also uses Subversion 1.6.5.

Thursday, September 03, 2009

Snow Leopard installation frees up a ton of disk space

Approximately 17 GB in my case. Not too shabby. Now I have to get Xcode 3.2 and the iPhone SDK add-on installed. BTW, the iPhone SDK installation now expects Xcode 3.2 to be previously installed, so make sure you've installed it off the Snow Leopard distribution. The 404 MB file size of the iPhone 3.0 SDK for Snow Leopard should be tip off if you've installed previous iPhone SDKs.

.NET thread local storage implementation kicks my butt

I got skooled today in .NET. I wrote a thread-local storage abstraction using named data slots some time ago. Avoid named data slots at all costs! Use the ThreadStaticAttribute instead. Not only is the ThreadStaticAttribute much easier to implement, but it performs better also. I had to wait till my code was in a near-prod environment before enough load could be generated to cause the race condition to occur. It took me about 2 days of debugging to find the issue. Most importantly, read the damn documentation before you attempt to write some threading code. There are some subtle issues in the .NET Base Class Library that I would have avoided if I had read the MSDN site. Very embarrassing.

From Microsoft:

The .NET Framework provides two mechanisms for using thread local storage (TLS): thread-relative static fields (that is, fields that are marked with the ThreadStaticAttribute attribute) and data slots. Thread-relative static fields provide much better performance than data slots, and enable compile-time type checking. For more information about using TLS, see Thread Local Storage: Thread-Relative Static Fields and Data Slots. (http://msdn.microsoft.com/en-us/library/system.threading.thread.allocatenameddataslot.aspx)

Monday, August 31, 2009

Mac Pro upgraded to Snow Leopard

Painless install of Snow Leopard on my early 2009 Mac Pro. I don't really notice much new. System seems a bit snappier, but that purely qualitative observation on my part. No numbers to back that up.

Tuesday, August 18, 2009

Know your SUT and your mocks

I was working with a colleague of mine tonight and he became confused with his unit test. It was an interesting exchange, so I thought I would write it up. He had a system under test (SUT), a service, that had a number of dependencies. The dependencies were mocked using a mocking framework (mockito in this instance). He was writing a test to get better code coverage in preparation for some refactoring and he started to add an expectation to the SUT. When he ran his test, the test failed, but the error lead you to believe that it was the improper use of matchers within mockito. It took him and I awhile to realize that he was trying to add expectations to a non-mock class. In hindsight, he should have picked up on this right away, as we have a coding convention of naming our mock object instances as mock*. The SUT does not follow this naming convention and hence you should see the problem right away. A little concerned that mockito didn't alert us to the fact that we were trying to add expectations to a non-mock instance. Moral of the story: Make your mock object instances stand out--name them appropriately so everyone knows that it's a mock.

Wednesday, August 12, 2009

My top 5 favorite Mac OS X apps/tools/utilities

One of my friends is buying his first Mac (a Mac mini) and I told him I would compile a list of tools and utilities that I use on my Mac systems. Here are my top 5 that I absolutely must have:


  • Google Quick Search Box/Quicksilver: I was a big fan of Quicksilver, but it seems to be dead. Sounds like the Quicksilver developer is now working with/for Google on something similar: Google Quick Search Box (QSB). Love QSB and it seems to be in active development too.


  • iTerm: Gotta have a command line. This one does tabbed terminal consoles.


  • TextMate: Great programmer's editor.


  • Versions: A good Subversion client for OS X.


  • Growl: Notification system. Extremely helpful.







Sunday, June 21, 2009

First reactions to Xcode 3.1.3

Code Sense seems to be much better. Acts intelligently and pressing Return on the suggestion selects the suggestion. It's been a while since I've been in Xcode, but I remember the Code Sense being somewhat odd. That doesn't seem to be the case now. BTW, I'm using Xcode from the iPhone SDK released last week.

Thursday, May 14, 2009

Learn IDE key mappings while pair programming

I'm a big believer in keeping the hands on the keyboard and minimizing the amount of mouse use when coding. Therefore, I tend to spend some time learning the keymappings for the IDE I am using. I'm most proficient with IntelliJ IDEA but I've also learned a good portion of the keymappings in Eclipse and Visual Studio+ReSharper.

I've been doing a fair amount of pair programming lately on my current gig, a good thing. One behavior that we have been practicing while pair programming is gently forcing the driver of the pair to use keymappings to activate various actions within the IDE. Neal Ford describes this in his book The Productive Programmer. Practicing this behavior while pair programming has proven very valuable to increasing our productivity while in the code base. Neal mentions the KeyPromoter plugin for IntelliJ; I've tried this plugin and I haven't become a big fan of it. Much easier if your navigator keeps you honest.

I've done this before with pair programming while working at Identix in 2004 with Hans Loedolff. Hans knew all the IntelliJ keymappings and could type at about 90 words per minute. He was an excellent pair programmmer.

nmon performance monitoring tool

One of the takeaways from yesterday's Tomcat Expert Series seminar was the use of nmon (Nigel's monitor), a curses-based performance monitoring tool. I had never heard of nmon before yesterday, so I was curious why I missed this tool in my IT travels. Seems the tool has originated out of IBM, originally on IBM's AIX Unix variant. The tool has been ported to Linux. More information here. If you're deploying onto Linux or AIX, it might be worthwhile to take a look at this tool and add it to your systems. Unfortunately it does not look like there's a version for Mac OS X yet. Hey, OS X is Unix too ;-)

Wednesday, May 13, 2009

Tomcat Expert Series here in Minneapolis

Attended the SpringSource Tomcat Expert Series seminar here in Minneapolis this morning at the Hyatt Regency. Filip Hanik of SpringSource presented. Filip is a major committer to the Apache Tomcat project. Excellent technical presentations on Tomcat and JVM performance tuning tips and debugging JVM memory and thread issues. Lots of good information around Sun's generational heap and garbage collecting the heap, If you get a chance to take this presentation in, you won't regret it. $75 USD for 3.5 hours and a nice lunch. Seemed like a nice turn out, probably 120 or so attendees. SpringSource seems to be picking up momentum in the JVM space with recent acquisitions of G2One (Groovy and Grails consulting and development) and Hyperic (web application monitoring and management tooling). Could be well positioned when the economy comes out of this funk it's currently in.

Friday, April 24, 2009

Adding GNOME to Ubuntu Server

I needed to add in an Xserver to my Ubuntu Server--Oracle 11g installer is graphical. I didn't want to play the redirecting of the X display back to OS X, so I did some searching and found this discussion. I'll reproduce the steps that I took. The forum posting has many different solutions.

Update your package system.
sudo apt-get update


Install the Ubuntu desktop package. This package seems to be a super package containing many package dependencies. It literally downloaded about 1.7 GB of software. Gdm is part of this install, so you don't have to do an individual install of that after the fact.
sudo apt-get install ubuntu-desktop



Gdm automatically starts the X system during bootup. To configure it to start, do the following:

sudo /etc/init.d/gdm start



You may need to reconfigure your video card, keyboard, etc. To do so, do the following:
sudo dpkg-reconfigure xserver-xorg


Thursday, April 23, 2009

Installing VMware Tools on Ubuntu Server

I'm brining up an Oracle 11g install on Ubuntu Server here at home, and I had a need to install VMware Tools on the server installation before I got hot and heavy into the Oracle installation. Here are some great instructions on how to do just that. I'm using VMware Fusion 2.0.4 on a Mac OS X 10.5.6 host system. Seems VMware has released the source for VMware Tools and you can now get it from an Ubuntu apt repository.

Saturday, April 11, 2009

Excellent Digg Dialogg with Trent Reznor

Excellent video with Trent Reznor of Nine Inch Nails. Kevin Rose of Digg hosts and the questions are from the community, voted up on Digg. Excellent content around Trent's efforts on alternative music distributions and business models. He also mentions his interactions with id Software and John Carmack. Has some nice comments about the programming profession. Well worth watching.

Sunday, April 05, 2009

Embedded domain components in Grails

The embedded component feature of Grails is not documented very well, in my opinion. Therefore, I thought I would create a blog entry so others don't have to spend the time trying to experiment with it to get it to work.


I recently spent some time working on a home project that I have implemented in Grails 1.1. Grails has a feature for embedding domain components into other domain classes. An embedded component participates in the domain class mapping to a database table; there is no join to an child embedded component table. In my domain object model, a TimeRecord is a domain component suitable for embedding. It doesn't live on its own, but is meant to be embedded as a reusable component throughout my domain object model. Grails has first-class support for embedded components, though it took me a bit of time to figure out how to get it to work. First the definition of the TimeRecord class:



class TimeRecord {
TimeRecordUnits units
BigDecimal value

static constraints = {
units(nullable: false)
value(nullable: false)
}
}

Nothing earth-shattering here. The reference to TimeRecordUnits is a Groovy enum. The TimeRecord class is not meant to be mapped to its own table in the database; it will become part of any domain object's table mapping whenever it is embedded in that domain object class. Thus, the TimeRecord class definition needs to reside inside some other domain object's Groovy file. Strange behavior, even for convention over configuration, but it does work.


Now embed the TimeRecord in another domain object class and that domain object's table mapping will also have TimeRecord properties mapped to it. Here is my Story class that has a TimeRecord contained in it:



class Story {

TimeRecord estimate

static embedded = ['estimate']

}

I've removed other Story properties to focus on the embedded component mapping. Grails has a static property named embedded that specifies the component object property that should participate as an embedded association. That's it. I put the TimeRecord definition in the Story.groovy file, directly after the Story definition. Everything maps correctly to the database and I don't get an extraneous time_record table being generated by GORM. Pretty cool.


I must say that domain object modeling in Grails is much, MUCH faster than it is in Java with Hibernate. I'm at least an order of magnitude faster with GORM in Grails than I was in Java and Hibernate. I'm hooked on Grails convention over configuration theme.


Powered by Zoundry Raven

Sunday, March 22, 2009

Grails domain object modeling with Groovy enums

I had a need to use enumerations within my object model in my Grails app today. I wrote up a Google Sites page about my solution. I am using Grails 1.1 for this solution.

Sunday, March 08, 2009

Having another look at Grails

It's been a while since I've really worked with Grails. I used it in 2007 for about 7 months, but we really didn't use it in a typical fashion, as the front end was done in Adobe Flex. 2007 was also fairly early in the life of Grails; I remember using version 0.5.6 when I started at the client.

I'm now building a sample application in Grails 1.0.4 and doing all the AJAX stuff in jQuery. I'm really impressed with Grails now! It's so much more productive than I remember it. Also, I have a couple of books that have been absolutely essential to getting me going with Grails again: The Definitive Guide to Grails, Second Edition and Groovy and Grails Recipes. I'm using IntelliJ IDEA 8.1 for all my development and its Groovy and Grails support is much better than I remember it. JetBrains really makes it easy to give them money every year for a personal license upgrade for IntelliJ.

I haven't been super pleased with the Grails documentation on the Grails site and hopefully SpringSource has a positive effect on this issue in the near future. My development has been plowing ahead very nicely. I really like that I don't have to restart the application server for every little change. That saves a ton of time and has a positive effect on your ability to stay focused on job at hand. Very impressed with Grails this time around.

Thursday, March 05, 2009

The amazing effect of Apple's iPhone platform and the App Store

Michael Tyson has a very relevant post about the amazing effect that Apple's App Store has been having on creative individuals who are driven enough to build applications for the iPhone platform. I'm around quite a few people who have iPhones. It's amazing to see and hear their enthusiasm for this great platform. Michael's post is a great testament that software development can be very rewarding. Great encouragement for those interested in looking at Objective-C and Cocoa Touch.

Tuesday, March 03, 2009

IntelliJ's support for @AspectJ pointcuts in Spring 2.x AOP

I came across a really nice feature in IntelliJ IDEA 8.1 (it may be in earlier versions, but I'm using 8.1). I've been doing some AOP work within Spring Framework 2.5.6, using the excellent @AspectJ pointcut annotations. Once you have everything configured in your Spring application context, IntelliJ will start to annotate where pointcuts are being applied within your code. The annotation/emblem shows up in the left hand gutter of the editor window, right next to the line numbers. Clicking on the emblem will cause a popup listing of all the advices that are applied at that particular join point. You can even navigate directly to the advice from the popup. Very cool. Eclipse has something similar with their AspectJ development tools (AJDT), but this is the first time I've seen something like this in IntelliJ, my preferred Java editor.