Click here to load reader

SOEN 343 Software Design

  • View
    23

  • Download
    0

Embed Size (px)

DESCRIPTION

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. - PowerPoint PPT Presentation

Text of SOEN 343 Software Design

  • SOEN 343Software DesignSection H Fall 2006Dr Greg Butlerhttp://www.cs.concordia.ca/~gregb/home/soen343h-f06.html

  • OutlineEncapsulation, Information HidingServletsMVCGRASP Controller principle (Larman 17.13)Using servletsIn Fowlers EAAFowlers data handling patterns

  • EncapsulationA programming/design language mechanism.A packaging / scoping mechanism for namesNames can refer to data, types, Especially, a means of packaging data.

    Data

  • Information HidingDesign principle by which a module is assigned a secret.A modules secret is usuallyA design decision.

    What type of design decisions might we want to hide from the clients of a module?

  • Information HidingOften 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?

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

  • Servlets, The General IdeaApplet 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).

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

  • Java Server PageServlet:Embed HTML inside code.

    JSPEmbed code inside HTML.

  • HelloWeb.jsp

    Hello Web!

  • Hello.jsp

    Hello

  • Java Server PageImplemented as a (special kind of) servlet.

  • Model-View-Controller (MVC)Model

  • Model-Views

  • GRASP: ControllerWho handles a system event?E.g. List MoviesMain choices: assign to a design entity representingOverall system, or subsystem (faade controller).A Use Case scenario (often named, e.g. ListMovieHandler).

  • GRASP: Controller Illustration

  • GRASP: Controller IllustrationPresentationApplication

  • Controller Illustration: Web-based EA

  • Server

    :Tut06ControllerServlet

    HTTP Get

    doGet(req,resp)

    g:Greeting

    req:

    setAttribute("Greeting",g)

    forward(".../Greeting.jsp")

    Greeting.jsp

    ...

    getAttribute(...)

    g

    getGreeting()

  • Web-based Enterprise ApplicationsThe big picture

  • Enterprise Applications: LayersDomainData SourcePresentation

  • List of Main Patterns To Be StudiedDomainData SourceTable Data GatewayTransaction ScriptDomain ModelData MapperRow Data GatewayFront ControllerTemplate ViewTransform ViewPage ControllerPresentationActive Record

  • EA: MVCDomainData SourceTable Data GatewayTransaction ScriptDomain ModelData MapperRow Data GatewayActive RecordFront ControllerTemplate ViewTransform ViewPage ControllerPresentation

  • EA: MVCDomainData SourceDomain ModelTemplate ViewPage ControllerPresentation

  • Example: GreetingGreeting

  • Enterprise Application PatternsDomainData SourceTable Data GatewayTransaction ScriptDomain ModelData MapperRow Data GatewayFront ControllerTemplate ViewTransform ViewPage ControllerPresentationActive Record

  • Data Source PatternsDomainData SourceTable Data GatewayTransaction ScriptDomain ModelData MapperRow Data GatewayActive RecordFront ControllerTemplate ViewTransform ViewPage ControllerPresentation

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

  • Example: Person-Grade TableTable attributes:name : Stringgrade : intnamegrade

  • Table Data GatewayPersGradeTDG

    - PersGradeTDG()+ find(name) : ResultSet+ findInRange(fg,tg) : ResultSet+ insert(name,grade) : void+ update(name,grade) : void+ delete(name) : void

  • Table Data Gateway: Find Code

  • Table Data Gateway: FindInRange

  • Active Record (Row Data Gateway)PersGradeARname : Stringgrade : intPersGradeAR(name, g)find(name) // like RDG// Can also have domain logicgetRank()

    No fields.Find methods return ResultSet

Search related