1 Layered Architecture
Total Page:16
File Type:pdf, Size:1020Kb
e-gov Architecture Application Architecture 1 Layered Architecture ................................................................................. 3 1.1 Introduction ..................................................................................... 3 1.2 Best practices................................................................................... 3 1.2.1 Choose a layered architecture ......................................................... 3 1.2.2 Apply design patterns to layer the architeture.................................... 6 2 Domain Layer .......................................................................................... 8 2.1 Introduction ..................................................................................... 8 2.2 Best practices................................................................................... 8 2.2.1 Introduce a domain layer in the architecture...................................... 8 2.2.2 Apply design patterns on the domain layer ........................................ 9 2.2.3 Utilize the full power of OO ............................................................10 2.2.4 Avoid the anemic domain model .....................................................10 2.2.5 Minimize the dependencies with other layers ....................................10 2.2.6 Unit test the domain layer..............................................................10 3 Service Layer..........................................................................................11 3.1 Introduction ....................................................................................11 3.2 Best practices..................................................................................11 3.2.1 Introduce a session façade in the architecture ..................................12 3.2.2 Introduce Business Delegates in the architecture...............................14 3.2.3 Introduce a Service Locator in the architecture .................................15 3.2.4 Apply Inversion of Control (IoC) .....................................................16 3.2.5 Avoid storing all business logic in the service layer. ...........................18 3.2.6 Use the service layer as an alternative entry point.............................18 3.2.7 Integration with the PersistenceLayer ..............................................20 3.2.8 Handle transactions in the Service Layer ..........................................20 3.2.9 Handling security in the Service Layer .............................................20 4 Persistence Layer ....................................................................................21 4.1 Problem..........................................................................................21 4.2 Solution..........................................................................................21 4.3 Best practices..................................................................................22 4.3.1 Understand the difference between the object and the RDBMS Model ...22 4.3.2 OO Model != existing RDBMS model ................................................22 4.3.3 Different object models can map to the same data model...................23 4.3.4 Leverage O/R Mapping tools...........................................................23 4.3.5 Use Object Inheritance Mapping where possible ................................23 4.3.6 Object relationship Mapping ...........................................................25 4.3.7 Buy vs build.................................................................................25 4.4 Persistence Frameworks....................................................................25 4.4.1 Java Data Objects (JDO)................................................................25 4.4.2 Enterprise Java Beans 2.x..............................................................26 4.4.3 Enterprise Java Beans 3 ................................................................27 4.4.4 Hibernate ....................................................................................28 4.4.5 Other J2EE/J2SE Persistence frameworks .........................................28 4.4.6 ADO.NET .....................................................................................28 4.4.7 Other .NET Persistence frameworks.................................................28 1 e-gov Architecture Application Architecture 5 Presentation Layer...................................................................................30 5.1 Introduction ....................................................................................30 5.2 Best practices..................................................................................30 5.3 Apply presentation tier design patterns ...............................................31 5.4 Best Practices..................................................................................32 5.4.1 Build upon an existing presentation framework .................................32 5.4.2 Choose a corporate standard..........................................................32 5.4.3 Develop with portal integration in mind............................................32 5.4.4 Have a strategic vision to integrate external applications into the corporate portal. .....................................................................................33 5.4.5 Add existing applications to the corporate Portal ...............................34 5.4.6 ASP.NET......................................................................................34 5.5 Presentation Frameworks ..................................................................35 5.5.1 Evolution of presentation frameworks in the J2EE space. ....................35 5.5.2 Java Server Faces (JSF).................................................................36 5.5.3 Apache Struts ..............................................................................37 5.5.4 Spring Web MVC...........................................................................38 5.5.5 WebWork ....................................................................................38 6 Overall design considerations ....................................................................40 6.1 Introduction ....................................................................................40 6.2 Best practices..................................................................................40 6.2.1 Minimize Network roundtrips ..........................................................40 6.2.2 Design patterns............................................................................40 6.2.3 Centralize Business Logic...............................................................42 6.2.4 Moving between tiers ....................................................................43 6.2.5 Design Patterns............................................................................43 6.3 Transactions ...................................................................................47 6.4 Exception handling...........................................................................47 6.5 Managing State ...............................................................................47 7 Managing the code base ...........................................................................48 7.1 Introduction ....................................................................................48 7.2 Best practices..................................................................................48 7.2.1 Setup sub projects in the development environment..........................48 7.2.2 Standardize the development environment.......................................48 7.2.3 Promote reuse through the sub projects...........................................48 7.2.4 Manage dependencies between the sub projects ...............................48 7.2.5 Apply a Modular approach to the development environment................49 7.2.6 Conclusion...................................................................................50 2 e-gov Architecture Application Architecture 1 Layered Architecture 1.1 Introduction Most enterprise applications are composed of a large number of components throughout the environment. In addition to that, these components often have different levels of abstraction. In order to adhere to the ever changing business requirements, how can we come up with an application architecture that supports: • Maintainability • Reusability • Scalability • Robustness • Security 1.2 Best practices This application architecture should: • Promote separation of concerns among the components in the architecture (Separating the user interface from the business logic , and the business logic from the data store) • Allow for changes to one part of the architecture to have a minimal impact on others parts. For example, changing a web interface should only have an impact on the user interface part of the application. • Promote reuse; components should follow the Low Coupling / High Cohesion pattern. o Individual components should be cohesive. o Unrelated components should be loosely coupled. • Allow for the different components of the architecture to be deployable independently • Allow for the different components of the architecture to be testable independently • Support the physical distribution across different tiers 1.2.1 Choose a layered architecture We need to separate the various components within the architecture into logical and technical layers. Components in a particular layer: • Should have