Web Application Design Notes Jeff Offutt http://www.cs.gmu.edu/~offutt/ SWE 642 Software Engineering for the World Wide Web N-Tier Architecture network middleware middleware Client Web Server Application Server DB Server Client-server 3-tier N-tier 3 December 2013 Offutt 2 1
Design Goals A major design goal of the N-tier architecture is separation of concerns : 1. Presentation 2. Logic 3. Data Also to support our seven criteria : 1. Maintainability 2. Security 3. Scalability 4. 3 December 2013 Offutt 3 Separation of Concerns Presentation HTML & JSP Data content Data representation Data storage Servlets & beans Data structures Beans & java classes Data base & files Oracle, sql 3 December 2013 Offutt 4 2
Separation of Concerns (2) doget() and dopost() should be simple and short Shift processing to other methods and classes Put complicated logic in non-servlet classes Put almost no logic in JSPs JSPs should present data they get from other classes JSP Use to process user input Use JSPs to present data that is on server Servlet Beans & Java classes DB 3 December 2013 Offutt 5 Design Specification Good Habits Software Requirements Baseline Information Architecture Specification Site map, Web Page Flows, Compositions, Labeling, Data Element Mappings Web Application Design High-Level Software Design Software Architecture and System Architecture Diagram Class Diagrams Sequence Diagrams Class Specifications 3 December 2013 Offutt 6 3
Model-View-Controller (MVC) The MVC architecture is a common abstraction in web application design Divides the responsibilities of objects Decreases coupling between objects and layers (supports easier maintenance) Helps divide the work supports development expertise areas One of the first web design patterns Probably over-used If I only have one tool, a hammer, all problems look like nails 3 December 2013 Offutt 7 Model-View-Controller (MVC) method calls events state query View Renders the model Requests updates from the model Sends user inputs to controller Allows controller to select view Model Encapsulates application state Responds to state queries Exposes application functionality Notifies views of changes change notification HTML / JSP view select user inputs data structures state change Java Controller Defines application behavior Maps user actions to model updates Selects a view for response One view for each function Graphic from Designing Enterprise Applications with the Java 2 Platform, Enterprise Edition, Nicholas Kassem et al., October 2000 3 December 2013 Offutt 8 4
Web Application Design Complexity Complexity HTML Pages Basic JSPs and JSPs with Design frameworks Servlets Modular with Modular Components Components and Enterprise beans SWE 642 JSPs JSPs JavaBeans components custom tags Graphic from Designing Enterprise Applications with the Java 2 Platform, Enterprise Edition, Nicholas Kassem et al., October 2000 JSPs JavaBeans components custom tags templates enterprise beans 3 December 2013 Offutt 9 Common Design Mistakes No design specifications and no comments in code Overly limiting collaboration amongst the development team only 1-2 people understanding and owning the design Coding for future requirements Don t code ahead requirements will always be different Instead, use a flexible design Choosing a design framework that is too complicated Then making it worse by only using part of the framework Using the be lazy parts of agile processes without using the do it better parts 3 December 2013 Offutt 10 5
Best Practices Establish a Software Requirements Baseline Create design specifications Use Java Doc Train all of the development team on the design patterns and design constructs selected for the application, especially the connection points between tiers 30 minute rule every person can explain design in 30 minutes Design/develop adaptable systems, using object-oriented principles Use meaningful package, class, method, and variable names 3 December 2013 Offutt 11 Web Application Design Summary SWE 642 teaches the basics, but only scratches the surface of designing web applications SWE 642 gives a solid grounding, but your knowledge is far from complete Dozens of design frameworks are available to help build better web applications Be sure to learn the concepts, not just the syntax! Practitioners and educators are learning more every day The web changes every aspect of software engineering 3 December 2013 Offutt 12 6