Friday, May 25, 2007

Too Much Code

With the numerous software frameworks in existence today, it is easy to question yourself as soon as you associate copying and pasting with software reuse. I use to think that developing user-interfaces for desktop applications involved a lot of redundant (redundant is a technical term for boring) code but had to correct myself the minute I started working with web applications. Instinctively the copying and pasting felt wrong and started searching for more "clever" development practices to apply to a somewhat daunting code base.

With Struts, a developer creates JSP pages, maps the functionality found in the JSP page to an Action via the struts-config file, then implements the Action to execute the desired functionality. You wash, rinse, and repeat for every single JSP page and watch the amount of code pile up even when implementing the simplest of web applications. A developer could spend more time on consolidating the code but runs the risk of decreasing the site's maintainability if the code becomes too generic. Sometimes people forget how clever they really are until they have to revisit a project where everything is handled with general terms. For me, it has been easier to focus on developing maintainable code through refactoring and documentation then worry about the number of files a web application contains.

Until I investigate more, I found a way to optimize the annoying "copying and pasting" design pattern by using code templates in your favorite IDE (my favorite is Eclipse). With Eclipse a user can make use of a number of built-in code templates and can add their own pretty easily. This is a pretty simple utility that can save a developer time but is often overlooked. I found two articles (part 1 and part 2) that go through the basics of using and creating code templates within Eclipse.

No comments: