Search code examples
javahtmljspdesign-patternstiles2

Design pattern for consistent UI


I have a Java based web app, which is going to be redesigned (i.e. mainly UI) from scratch.

Now here are the requirements:

  1. The major changes are going to be in the UI layer (where it has to work on multiple devices like desktop/mobile/tablet with small changes in respective UI views)

  2. The UI changes would cause changes in the Action layer and "MAY" also cause some slight changes in Service layer

  3. I want the entire web app (all JSPs) to forcefully use a specific template (Header/Body/Footer)

Now my question is which design pattern would be most appropriate to use.

I am from a UI background (and less into Java). So it would be great if you could explain in very SIMPLE/BASIC terms.


Solution

  • For this case, the basic problem is the separation of concerns namely the UI Concern which renders the UI from the data and the Business Logic which generates the data. For these type of problem Model-View-Controller OR MVC is best suited,

    To explain roughly :

    Model - is the data mode and business log which generates data

    View - the Visual representation of data or UI as we know it

    Controller - Is an engine which selects the correct view depending on the Data generated

    So far MVC remains the most preferred design (or architectural ) pattern for web application. There are numerous MVC frameworkfor java.

    For MVC, check out these links 1,2, this one is struts specific and quite detailed. Don't get overwhelmed :)

    From the available frameworks (which are, I heard around 50 odd) Struts and Spring MVC remains the most popular.

    Checkout Developing Spring MVC , Developing struts application.

    for your listed problems #1 and #2 MVC is good. For your specific problem of #3, there is Tiles Framework, which works both with Struts and Spring MVC.

    As I understand, you are new to Java and web development, this should be just a good starting point.