Development and Deployment Structures – the perfect way to build a web application

It is always beneficial to have a development and a deployment structure when building an application. It is a perfect way to build a web application. First of all let’s see what is the difference between them.

Development Structure
It is the structure or hierarchy of files that you make in order to make a separation of content based on factors like

  • project modules – every module has its own folder structure
  • repository policy – your company might follow some standardized hiearchical pattern for versioning
  • separation of source code from compiled one – they must not be mixed anytime
  • separation of tiers in the application – each tier might use different components so they better remain separated

An example for the development structure might be as follows:

[Project]
     |
     |-------[Module]
                |
                |-------[src]  //for all business tier components
                |
                |-------[web]  //for all presentation tier components
                |
                |-------[etc] //for all configuration components that the deployment structure might require
                |
                |-------[lib]  // 3rd party packages required for the source code

It can be noticed that the development structure is not based on any framework or language or environment. It is a notional hierarchy which results in a clean environment for ease of use,development and also for maintenance or versioning. In short, the development structure is only for storage purposes and never for executional purpose. You have to remember that you may not be able to run any component from the development structure.

Deployment structure
When you finish coding some part of the module you need to test the part by executing it with the help of some framework or a standardized model or pattern. For this you need to compile your source code and then place it in a specific structure for providing it to the execution environment. The hierarchy which is required by the environment to execute your code module is called as the deployment structure.

For example the simplest of the deployment structure which you first come across in a J2EE environment is the JSP/Servlet deployment structure. Here your hierarchy will be always as follows:

[Project]
     |
     |------[WEB-INF]
		|
		|-------[classes]
 		|
		|-------[lib]
		|
                |-------web.xml

The deployment structure is dependent on a framework or specification. Thus different frameworks will have different deployment structures.

Recommendation
I recommend you to always have these structures since it can separate out concerns very well and most important, it helps you to code in a neat and clean manner and is very easy for versioning. The major advantage of having a separate structure for development is that no matter what framework you use your development structure will remain constant for the rest of its life. If you try to directly code within the framework paradigms you will get lost when you will be required to change the same application to work with a different framework which would be having a different approach and style of structuring.

Conversion
There are tools which help you to convert the development structure to a deployment structure easily without the headache of individual compilation of your source files. One such tool is Apache ANT. It is a powerful tool which helps you to convert the development structure into the deployment structure without your need to touch the source code directly. Everything right from creating the structure to deploying your application in the server can be done through Ant by simply creating an XML file.

Conclusion
Normally in an enterprise you would be working directly with IDE’s which allow you to work in workspaces (as in Eclipse). The structure that you make in these IDE’s is actually the development structure. Internally the IDE’s make use of Ant to convert this into the deployment structure without you ever realizing it.

But if you don’t need an IDE for your work, always remember to consider the separation of development and deployment. It will always help for any kind of situation!

10 thoughts on “Development and Deployment Structures – the perfect way to build a web application

  1. What about Maven2? It provides convenient project structure and greatly simplifies development/deployment tasks. BTW generated with Maven2 projects can be easily made Eclipse projects.

  2. I wish I could read this post when I was a newbie.
    For those using Eclipse, I would also recommand to use “user libraries” for versionning.
    This is particularly helpful when you have to use different tools/libraries/frameworks (Hibernate, Struts, Displaytag…) which generally provide a set of jars. If you don’t do that it quickly becomes a mess. It becomes worse when you have to upgrade one of those components.
    01es is right, have a look at maven.

  3. Good Tutorial. The previous comment shows:

    “If you have not yet understood what is the use of Ant, read my article on Development and Deployment Structures – the perfect way to build web applications.”

    which is taken from the ANT tutorial, but creates a circular reference here. 🙂

  4. Yes Stephane,

    Its because of the pingback functionality in WordPress which puts a link in the comments section of the post, if I link to it from another post.

    It’s helpful at times, if you want to know which other articles in this site are related to the current one.

  5. maven is good tool for lazy people. it can be a big repository of config file on the web. just like those xml coding embedded in your web pages if you were using front page as the tool for your web pages . the the side products coming with it are messy codes that you don’t know what are they and for what they are there, difficult to debug.

  6. this was a great explanation of development vs deployment and how to tools are used in that pipeline. thank you. 🙂

    now moving on to your Ant tutorial…

Leave a Reply

Your email address will not be published. Required fields are marked *