Java architect with UST Global Biju has posted 5 posts at DZone. View Full User Profile

The Power of Copy and Paste

10.26.2010
| 4656 views |
  • submit to reddit

A reasonably large sized “Enterprise” Java web application ends up being multi-tiered , multi-layered, multi-moduled in that order,  with at least a few million dependencies. The task of putting together such an application from scratch is truly daunting.

So how do you go about creating an application from scratch? I have a few favorite techniques that I have faithfully followed over the years:

  • Copy an existing working application;start trimming it until I get to the point where I have an “archetype” that I can start back from.
  • Start from one of the archetypes provided by maven. Most of the standard maven archetypes (obtained using mvn archetype:generate) are very lightweight, but could be a reasonable starting point.
  • Use Appfuse as a starter application. Appfuse though is starting to get a little bit dated now, with no updates for the last year

All of these approaches follow the common theme of “Copy and Paste” to create an application.

Now, copy and paste helps you kick-start an application, once you have started an application how do you keep adding functionality, after all most of the code structure would look similar – In Java you would add a new entity, a corresponding DAO to manage the persistence of the entity, a service tier, a controller, a view and so on.

The Rails folks did a wonderful job understanding that providing a simple way to kick-start, add functionality and pull in dependencies, is the quickest way to developer nirvana. Well, people who work with Rails are lucky, we Java guys don’t have that option, until now that is (Yes there is Grails, Lift, but these have not been an option in the enterprise shops that I have worked in).

Roo is turning out to be a wonderful alternative. With a few commands , you have a fairly green looking application up and running with all dependencies nicely pulled in. Adding functionality is equally easy; the roundtrip experience from creating an entity, to viewing the entity in a web page almost has the feel of a Rails based development. Well, Roo is still maturing, so it is not an option where I work yet, however that still leaves the “Copy and Paste" as a viable alternative for now!!. A simple way that I follow to add functionality to an application that I am working on is to simply start the Roo console, create the entities in roo, run the push in refactor and then creatively “copy and paste”.

"Copy and Paste" the most under-rated way of expanding code.

Published at DZone with permission of its author, Biju Kunjummen.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Tags:

Comments

Cloves Almeida replied on Tue, 2010/10/26 - 2:44pm

Seam has long provided the "seam-gen" tools which scaffolds a lot and is "enterprise compliant". However, what I didn't like about Rails scaffolding is that while you get the 80% of you needs really fast, the other 20% is a PITA to achieve.

IMO, what's really missing fo Java EE to become "enterprise developer nirvana" is a truly extensible UI component model like Swing. JSF is flawed and Vaadin is a step in the right direction. We should learn from recent developments and make UI layouting/styling declarative.

 

Nemanja Ristic replied on Tue, 2010/10/26 - 3:55pm

I have used Roo in my latest project and it is a great tool. I have created entities, set up ORM tool and generate few find methods, just to see how it works. And it helps a lot in order to start a project. My recommends for this tool and the guys on such a great idea. :) Especially, cause I love console. :D

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.