1 / 33

SOEN 343 Software Design

SOEN 343 Software Design. Section H Fall 2006 Dr Greg Butler http://www.cs.concordia.ca/~gregb/home/soen343h-f06.html. Outline. Encapsulation, Information Hiding Servlets MVC GRASP Controller principle (Larman 17.13) Using servlets In Fowler’s EAA Fowler’s data handling patterns.

myra-hurley
Télécharger la présentation

SOEN 343 Software Design

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SOEN 343Software Design Section H Fall 2006 Dr Greg Butler http://www.cs.concordia.ca/~gregb/home/soen343h-f06.html

  2. Outline • Encapsulation, Information Hiding • Servlets • MVC • GRASP Controller principle (Larman 17.13) • Using servlets • In Fowler’s EAA • Fowler’s data handling patterns

  3. A programming/design language mechanism. A packaging / scoping mechanism for names Names can refer to data, types, … Especially, a means of packaging data. Access points at interface Encapsulation

  4. Information Hiding • Design principle by which a module is assigned a “secret”. • A module’s secret is usually • A design decision. • What type of design decisions might we want to hide from the clients of a module?

  5. Information Hiding • Often one hides, e.g. • Data representation. • Choice of algorithm. • Interface details / access mechanism of external entity (e.g. database, hardware) • … • Goal: particular design choice “invisible” to clients. • Why would we want to do this?

  6. Information Hiding • Information Hiding may or may not be supported a the programming language level.

  7. Servlets, The General Idea • Applet as a client side Java application. • Servlet as a server side technology for implementing part of the functionality of an application. • HTTP (URL) requests cause a servlet to be: • Instantiated (if it did not exist). • Run. • The servlet builds a response which is then sent back to the client (usually in the form of HTML).

  8. Servlet: HelloWeb public class HelloWebServlet extends HttpServlet { protected void doGet( HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ServletOutputStream out = response.getOutputStream(); out.println("Hello Web!"); } }

  9. Java Server Page • Servlet: • Embed HTML inside code. • JSP • Embed code inside HTML.

  10. HelloWeb.jsp <%@ page contentType="text/html; charset=iso-8859-1" language="java" ... %> <html> <body> Hello Web! </body> </html>

  11. Hello.jsp <%@ page contentType="text/html; charset=iso-8859-1" language="java" ... %> <html> <body> Hello <%= request.getParameter("name") %> </body> </html>

  12. Java Server Page • Implemented as a (special kind of) servlet.

  13. Controller View Model-View-Controller (MVC) Model

  14. Model-Views

  15. GRASP: Controller • Who handles a system event? • E.g. “List Movies” • Main choices: assign to a design entity representing • Overall system, or subsystem (façade controller). • A Use Case scenario(often named, e.g. ListMovieHandler).

  16. GRASP: Controller Illustration

  17. GRASP: Controller Illustration Presentation Application

  18. Controller Illustration: Web-based EA

  19. Web-based Enterprise Applications • The big picture …

  20. Enterprise Applications: Layers Presentation Domain Data Source

  21. List of Main Patterns To Be Studied Page Controller Template View Presentation Front Controller Transform View Domain Model Transaction Script Domain Active Record Row Data Gateway Data Mapper Data Source Table Data Gateway

  22. EA: MVC Page Controller Template View Presentation Front Controller Transform View Domain Model Transaction Script Domain Active Record Row Data Gateway Data Mapper Data Source Table Data Gateway

  23. EA: MVC Page Controller Template View Presentation Domain Domain Model Data Source

  24. Page Controller (Greeting servlet) Template View (Greeting.jsp) Example: Greeting Greeting

  25. Enterprise Application Patterns Page Controller Template View Presentation Front Controller Transform View Domain Model Transaction Script Domain Active Record Row Data Gateway Data Mapper Data Source Table Data Gateway

  26. Data Source Patterns Page Controller Template View Presentation Front Controller Transform View Domain Model Transaction Script Domain Active Record Row Data Gateway Data Mapper Data Source Table Data Gateway

  27. Data Source Patterns • Hide SQL. • Provide an abstraction for • One data row. • A collection of data row(s).

  28. Example: Person-Grade Table Table attributes: • name : String • grade : int name grade

  29. Table Data Gateway PersGradeTDG - PersGradeTDG() + find(name) : ResultSet + findInRange(fg,tg) : ResultSet + insert(name,grade) : void + update(name,grade) : void + delete(name) : void

  30. Table Data Gateway: Find Code

  31. Table Data Gateway: FindInRange

  32. Active Record (Row Data Gateway) PersGradeAR name : String grade : int PersGradeAR(name, g) find(name) … // like RDG // Can also have domain logic getRank()

More Related