Presentation is loading. Please wait.

Presentation is loading. Please wait.

Design Patterns CSE 740 Software Engineering Presentation Tim Jowers October 10, 2002.

Similar presentations


Presentation on theme: "Design Patterns CSE 740 Software Engineering Presentation Tim Jowers October 10, 2002."— Presentation transcript:

1 Design Patterns CSE 740 Software Engineering Presentation Tim Jowers October 10, 2002

2 Agenda Summary Example Thoughts Questions?

3 de·sign pat·tern “A template of abstract architectural elements that can be used to guide you in generating your design.” Pfleeger, p.299 “Identifies the participating classes and instances, their roles and collaborations, and the distribution of responsibilities.” GoF, p.219 of Pfleeger Something that occurs again and again.

4 Inheritance vs. Aggregation Base InheritanceAggregation Method_1 Method_2 Method_3 Subclass Method_A Method_B Method_C Outer Method_1 Method_2 Method_3 Subclass Method_A Method_B Method_C Method_A Method_B Method_C Interface Method_1 Method_2 Method_3 Implements Method_1 Method_2 Method_3 Method_A Method_B Method_C Does it affect how the code is executed?

5 Viewpoint 1: Object Associations One class uses another internally. Visible Class “Inner Class” External Interface Adapter, façade, delegation, composition, … Controller + Model in MVC?

6 Adapter Convert the inner class’ interface into an interface usable by another object. Adaptee Adapter Adaptee Target Adapter Adaptee Target GoF, p141 Pat. Java, p178 GoF, p141

7 Subsystem Classes Façade Provide a unified interface to a set of interfaces in a subsystem. Package Façade Façade (e.g. Compiler) Scanner Code Generator Parser Bytecode Stream Java GoF, p187 1Ifc3 Interface 2 4 ifc5

8 Delegate To allow an object to share implementation without inheritance, send part of its work to another object. Pat. Almanac, p155 Person Instructor TA Student Problem: Inheritance is fixed. Roles are mutually exlusive. Person Instructor TAStudent Solution: Variously instantiate appropriate class. Issue? Does aggregation properly model Plays-Role- Of? - Bonnell

9 How many class relations exist? Visible Class “Inner Class” External Interface Visible Class “Inner Class” The Visible Class can … 1.Expose functionality. 2.Return an inner class by interface, casting to [abstract] base class 3.Relay data and/or method calls to inner class(es)

10 Viewpoint 2: Context/Domain Patterns in Scientific Computing Accounting software Architectural software Banking, Business Customer Interaction Inventory Control Telemetry …

11 Viewpoint 3: Categorization Behavioral Structural Security Concurrent Systems Distributed Systems Fault-tolerant Systems Frameworks Integration Transaction Processing Performance Database

12 Sample Application Small World Phenomenon / Six Degrees of Separation –Randomly pick anyone on earth. –You know someone who knows someone who knows someone ( Six Degrees) … who knows that person. Relate people by –Friends –Ancestry –Experiences

13 GUI Patterns (1) Message loop – Microsoft Windows –Based on a “Window”. May be Command Pattern in GoF p233. Message handlers – X Windows –Based on a widget. Callback pattern. Listeners – Java Swing –Based on a component –Same as “Observer” pattern in GoF. Sun built on the Work of Others – specifically GoF See Sun’s Design Patterns at java.sun.com –Iterator in GoF and Java etc.

14 GUI Patterns (2) At least Four Possible GUI’s 1.Edit personal data 2.View/Edit friend relationships 3.View/Edit family relationships 1.Import from Ancestry files 2.Manual Interface 4.View/Edit experiences on self and/or others 1.Updates from Events Organizers 2.Maybe import from government HIPAA database Called the “Views” in Model-View-Controller pattern. P288 of Pfleeger.

15 MVC (1) VIEWS CONTROLLER Factory Method Controller List-based Controller Tree-based instantiates MODEL

16 MVC (2) Factory Method Controller List-based Controller Tree-based instantiates HTTPJEE SERVER

17 J2EE MVC Java Server Programming. J2EE Edition, Wrox, 2000, p. 1223. Web Browser Applet Servlet Engine JSP Servlet Web Server EJB Server Session Bean Entity Bean Database View Presentation Logic Controller Business Process Model Business Logic & State

18 Some Patterns on Sun’s Site Pattern NameDescription Business DelegateBusiness Delegate [ACM01] Reduce coupling between Web and Enterprise JavaBeans TM tiersACM01 Composite EntityComposite Entity [ACM01] Model a network of related business entitiesACM01 Composite ViewComposite View [ACM01] Separately manage layout and content of multiple composed viewsACM01 Data Access Object (DAO)Data Access Object (DAO) [ACM01] Abstract and encapsulate data access mechanismsACM01 Fast Lane ReaderFast Lane Reader Improve read performance of tabular data Front ControllerFront Controller [ACM01] Centralize application request processingACM01 Intercepting FilterIntercepting Filter [ACM01] Pre- and post-process application requestsACM01 Model-View-ControllerModel-View-Controller Decouple data representation, application behavior, and presentation Service LocatorService Locator [ACM01] Simplify client access to enterprise business servicesACM01 Session FacadeSession Facade [ACM01] Coordinate operations between multiple business objects in a workflowACM01 Transfer ObjectTransfer Object [ACM01] Transfer business data between tiersACM01 Value List HandlerValue List Handler [ACM01] Efficiently iterate a virtual listACM01 View HelperView Helper [ACM01] Simplify access to model state and data access logicACM01 Reference: http://java.sun.com/blueprints/patterns/catalog.html

19 Thoughts How do Design Patterns relate to … Algorithms … are these software design patterns? Data Structures …essential to Patterns and Algorithms. Software Architectures …Design Patterns “In the Large”? …Terminology often How To setup Product X. … How to apply patterns to COTS integration.

20 Broadened Vision Read the patterns Think about the patterns Think about your software design Use the patterns Life is good When you Build on the Work of Others

21 References Design Patterns. Elements of Reusable Object-Oriented Software, Erich Gamma et al, 1995. Software Engineering. Theory and Practice, Shari Pfleeger, 2001. The Pattern Almanac, Linda Rising, 2000. Patterns in Java, Mark Grand, 1998. Java Server Programming. J2EE Edition, Wrox, 2000. Web links… Sun J2EE Java BluePrints, http://java.sun.com/blueprints/patterns/ http://java.sun.com/blueprints/patterns/ Knowledge and Design Specification Reuse: the Domain Theory, http://www.co.umist.ac.uk/centre_hci/domain3.htm http://www.co.umist.ac.uk/centre_hci/domain3.htm Pattern-Oriented Software Architecture: Patterns for Concurrent and Networked Objects, http://www.cs.wustl.edu/~schmidt/POSA/. Also has a nice tutorial for this semester, Oct. 2002. http://www.cs.wustl.edu/~schmidt/POSA/ Architecture as Object Models of Software, Eyoun Eli Jacobsen, 2201.

22 Extra Time Slides Chain of Responsibility Design Pattern http://www.stal.de/slides.html

23

24 /**Instances of this class are used to represent an open area in a * warehouse, an office building or retail floor. */ class Area extends SecurityZone { //... /** * This method is called by the notify method so that this object can have * a chance to handle measurements. */ boolean handleNotification(int measurement, Sensor sensor) { if (sensor instanceof TemperatureSensor) { if (measurement > 150) { fireAlarm(this); return true; } // if } //... //... return false; } // handleNotification(int, Sensor) } // class Area Chain of Responsibility Patterns in Java, Vol. 1

25

26


Download ppt "Design Patterns CSE 740 Software Engineering Presentation Tim Jowers October 10, 2002."

Similar presentations


Ads by Google