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.
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.
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.
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.
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.
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!