1 / 24

Art for Chapter 8, Object Design: Reusing Pattern Solutions

Art for Chapter 8, Object Design: Reusing Pattern Solutions. Problem. System. Solution objects. Custom objects. Application objects. Requirements gap. Object design gap. Off-the-shelf components. System design gap. Machine.

halla-sykes
Download Presentation

Art for Chapter 8, Object Design: Reusing Pattern Solutions

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. Art for Chapter 8,Object Design:Reusing Pattern Solutions

  2. Problem System Solution objects Custom objects Application objects Requirements gap Object design gap Off-the-shelf components System design gap Machine Figure 8-1, Object design closes the gap between application objects identified during requirements and off-the-shelf components selected during system design.

  3. Figure 8-2, Activities of object design (continued on next slide). Select Subsystem Specification Reuse Identifying missing Identifying components attributes & operations Specifying visibility Adjusting components Specifying types & signatures Identifying patterns Specifying constraints Specifying exceptions Adjusting patterns

  4. Figure 8-2, Continued. Check Use Cases Restructuring Optimization Revisiting Optimizing access inheritance paths Caching complex Collapsing classes computations Delaying complex Realizing associations computations

  5. Hashtable Hashtable put(key,element) put(key,element) get(key):Object get(key):Object containsKey(key):boolean containsKey(key):boolean containsValue(element):boolean containsValue(element):boolean MySet MySet put(element) put(element) containsValue(element):boolean containsValue(element):boolean Figure 8-3, An example of implementation inheritance (continued on next slide). Object design model before transformation Object design model after transformation table 1 1

  6. /* Implementation of MySet using inheritance */ class MySet extends Hashtable { /* Constructor omitted */ MySet() { } void put(Object element) { if (!containsKey(element)){ put(element, this); } } boolean containsValue(Object element){ return containsKey(element); } /* Other methods omitted */ } /* Implementation of MySet using delegation */ class MySet { private Hashtable table; MySet() { table = Hashtable(); } void put(Object element) { if (!containsValue(element)){ table.put(element,this); } } boolean containsValue(Object element) { return (table.containsKey(element)); } /* Other methods omitted */ } Figure 8-3, continued.

  7. Inheritance Inheritance Taxonomy for Reuse Inheritance detected Inheritance detected Specification Implementation during specialization during generalization Inheritance Inheritance Figure 8-4, Inheritance meta-model.

  8. Client ClientInterface LegacyClass Request() ExistingRequest() Adapter Request() Figure 8-5, An example of design pattern: Adapter. adaptee

  9. Client Set Hashtable add(element) put(key,element) MySet add(element) Figure 8-6, Applying the Adapter design pattern to the Set problem of Figure 8-3. adaptee

  10. Arena LeagueStore LeagueStoreImplementor Stub Store XML Store JDBC Store Implementor Implementor Implementor Figure 8-7, Applying the Bridge design pattern for abstracting database vendors. imp

  11. Array Comparator MyString greaterThan() compare() equals() MyStringComparator compare() Figure 8-8, Applying the Adapter design pattern for sorting Strings in an Array. See source code in Figure 8-9. adaptee

  12. /* Existing target interface */ interface Comparator { int compare(Object o1, Object o2); /* ... */ } /* Existing client */ class Array { staticvoid sort(Object [] a, Comparator c); /* ... */ } /* Existing adaptee class */ class MyString extends String { boolean equals(Object o); boolean greaterThan (MyString s); /* ... */ } /* New adapter class */ class MyStringComparator implements Comparator { /* ... */ int compare(Object o1, Object o2) { int result; if (o1.greaterThan(o2)) { result = 1 } elseif (o1.equals(o2)) { result = 0; } else { result = -1; } return result; } } Figure 8-9, Adapter design pattern example.

  13. Application NetworkConnection NetworkInterface open() send() close() receive() send() setNetworkInterface() receive() LocationManager Ethernet WaveLAN UMTS open() open() open() close() close() close() send() send() send() receive() receive() receive() Figure 8-10, Applying the Strategy pattern for encapsulating multiple implementations of a NetworkInterface.

  14. TheftApplication HouseFactory createBulb() createBlind() EIBFactory LuxmateFactory createBulb() createBulb() createBlind() createBlind() LightBulb Blind EIBBulb LuxmateBulb EIBBulb LuxmateBulb Figure 8-12, Applying the Abstract Factory design pattern to different intelligent house platforms

  15. Match play() replay() GameBoard Figure 8-13, Applying the Command design pattern to Matches in ARENA. * Move execute() «binds» TicTacToeMove execute() ChessMove execute()

  16. Top panel Main panel Button panel Figure 8-14, Anatomy of a preference dialog. Aggregates, called Panels, are used for grouping user interface objects that need to be resized and moved together.

  17. Figure 8-15, UML object diagram for the user interface objects of Figure 8-14. prefs:Window top:Panel main:Panel buttons:Panel title:Label c1:Checkbox ok:Button c2:Checkbox cancel:Button c3:Checkbox c4:Checkbox

  18. move() resize() Figure 8-16, Applying the Composite design pattern to user interface widgets. * Component move() resize() Label Button Checkbox Composite Window Panel Applet

  19. WORequest Figure 8-17, An example of dynamic site with WebObjects. WebBrowser WebObjectsApplication WebServer WOAdaptor WoRequest Template EOF StaticHTML RelationalDatabase

  20. WOAdaptor WORequest WebServer WOSessionStore * WOApplication * * * WOSession WOComponent DynamicElement * Figure 8-18, WebObject’s State Management Classes. The HTTP protocol is inherently stateless.

  21. Arena LeagueOwner Statistics League Game Tournament Player TicTacToe Move Match Chess Result Figure 8-19, ARENA analysis objects related to Game independence.

  22. Tournament Game createMatch() createStatistics() TicTacToe Chess createBulb() createBulb() createBlind() createBlind() Match Statistics TTTMatch ChessMatch TTTStats ChessStats Figure 8-20, Applying the Abstract Factory pattern to Games

  23. Match ReplayedMatch Move execute() TicTacToeMove GameBoard ChessMove Figure 8-21, Applying the Command design pattern to Matches and ReplayedMatches in ARENA. * nextMove() play() previousMove() replay() «binds»

  24. Figure 8-22, Applying the Observer design pattern to maintain consistency across MatchViews. observers Subject Observer * 1 subscribe(Subscriber) update() unsubscribe(Subscriber) notify() GameBoard MatchView state gameBoard getState() update() playMove()

More Related