Tuesday, July 29, 2008

Eclipse Tools You Should Be Using

I've written enough Java code in Emacs, Notepad, and Nano to know a good thing when I see it -- and Eclipse is a good thing! Pretty colors, line numbering, and CTRL+Space!! But seriously, there are a lot of cool things you can use with the software to make it even better.

Saving Tactics
It may seem a bit tedious, but I've got my Eclipse set up to do a bit of formatting every time I tap CTRL+S (which is a lot). It organizes my imports, formats my if statements, cleans up my whitespace, and, of course, saves the file. There are a number of options that differ version-to-version so I won't go into specifics but this is a nice way to keep your code clean and readable, especially working in a team environment.

Write buggy code? Fall into silly bug traps? Too lazy for JUnit? Or just like to try new plug-ins? Try out FindBugs! You can run it fairly quickly over your project and let it discover common ocde flaws, bad paterns, code smells, and code that's just on the fritz. Trust me.

Code Templates
Whether its method signature templates, comment defaults, or javadoc headers, using project-specific class templates are a great way to give your code formatting consistency. For example, I am working on an open-source project and need to include appropriate licensing headers atop each class. So instead of using copy-and-paste each time I make a class, all classes I create in my project automatically start with this text.

Of course, there's tons of things I haven't touched on here but these have greatly impacted my coding and make the process not only quicker and easier for me, but gives me better quality code as well. Maybe some of you can benefit as well! I also left some references you may find useful. Feel free to add others in the comments. 'Til next time!

Carl Scott
Software Developer, Solertium Corporation
View Carl Scott's profile on LinkedIn View Carl Scott's ohloh profile


Friday, July 25, 2008

RESTful Client-Side tools for GWT

I guess this is more of an announcement than a blog, but I just wanted to do a quick follow up to my last blog to mention some new developments pertaining to using a RESTful approach to GWT.

In my last blog, I spoke of RestLet, a server-side Java framework for REST. When I first learned of this technology, my cronies at Solertium Corporation and I fully embraced the concept, even doing some development on the open-source tool. Between then and now, I have been experimenting with client-side tools that provide reliable API through GWT to a RESTful server.

I first found GWT-REST, which if you saw my comments, I found to be pretty usable. Like the original developers of RestLet, though, I found it to have almost too much going on to make it work for me at the time. In addition, since, at the time, I have a strong code pattern that worked, it didn't make me want to go through the trouble of refactoring. After speaking with their development team, though, it looks to be strong in the future.

Since then, the RestLet guys have announced the release of a Restlet-GWT module, a port of RestLet to GWT, supported by the release of GWT 1.5. You can check out the official announcement here:

I am interested in seeing the differences between this and GWT-REST, but from my initial reading it seems that the RestLet version is an attempt at a direct port as opposed to something customized to have client-side conveniences implemented -- which I feel has strong and weak points, but the good should outweigh the bad here. I'm excited to see the implementation details, though! If you want a quick overview, the RestLet wiki provides pretty pictures and diagrams:

Again, I want to express that the RESTful method is more of an alternative to RPC than a replacement, both having benefits and drawbacks. The main drawback to RPC that has turned me to this approach is the tight client-server coupling issues and the limitations it enforces on your back-end server technologies.

My suggestion -- give Restlet's GWT module a shot. Like I said, it's an alternative, and it works right alongside RPC so it's not an either-or situation. We all have our own ways of getting the job done, but I'm always excited to hear of new developments and try them out, especially ones like these which make my job that much easier!

Thanks for your time in reading this. Feel free to comment with opinions for or against REST in GWT as I'd love to hear both sides. Also, if you'd recommend any technologies, again, feel free.

Carl Scott
Software Developer, Solertium Corporation
View Carl Scott's profile on LinkedIn View Carl Scott's ohloh profile