1 / 23

Object Design: Bridging the Gap

Object design closes the gap between application objects identified during requirements and off-the-shelf components selected during system design.

bonanno
Download Presentation

Object Design: Bridging the Gap

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. 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.

  2. 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

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

  4. 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

  5. /* 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.

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

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

  8. 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

  9. 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

  10. 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

  11. /* 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.

  12. 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.

  13. 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

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

  15. 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.

  16. 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

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

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

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

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

  21. 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

  22. 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»

  23. 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