Presentation is loading. Please wait.

Presentation is loading. Please wait.

Using UML, Patterns, and Java Object-Oriented Software Engineering Art for Chapter 8, Object Design: Reusing Pattern Solutions.

Similar presentations


Presentation on theme: "Using UML, Patterns, and Java Object-Oriented Software Engineering Art for Chapter 8, Object Design: Reusing Pattern Solutions."— Presentation transcript:

1 Using UML, Patterns, and Java Object-Oriented Software Engineering Art for Chapter 8, Object Design: Reusing Pattern Solutions

2 Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 2 Problem Machine System design gap Object design gap Requirements gap System Application objects Solution objects Custom objects Off-the-shelf components Figure 8-1, Object design closes the gap between application objects identified during requirements and off-the-shelf components selected during system design.

3 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 3 Figure 8-2, Activities of object design (continued on next slide). Specifying constraints Specifying types & signatures Identifying patterns Adjusting patterns Identifying missing attributes & operations Specifying visibility Specification Specifying exceptions Reuse Identifying components Adjusting components Select Subsystem

4 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 4 Figure 8-2, Continued. Collapsing classes RestructuringOptimization Revisiting inheritance Optimizing access paths Caching complex computations Delaying complex computations Check Use Cases Realizing associations

5 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 5 Figure 8-3, An example of implementation inheritance (continued on next slide). HashtableMySet put(element) containsValue(element):boolean put(key,element) get(key):Object containsKey(key):boolean containsValue(element):boolean Object design model before transformationObject design model after transformation HashtableMySet put(element) containsValue(element):boolean put(key,element) get(key):Object containsKey(key):boolean containsValue(element):boolean table1 1

6 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 6 Figure 8-3, continued. /* 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 */ }

7 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 7 Figure 8-4, Inheritance meta-model. Inheritance Specification Inheritance Implementation Inheritance for Reuse Taxonomy Inheritance detected during generalization Inheritance detected during specialization

8 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 8 Figure 8-5, An example of design pattern: Adapter. ClientInterface Request() adaptee LegacyClass ExistingRequest() Adapter Request() Client

9 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 9 Figure 8-6, Applying the Adapter design pattern to the Set problem of Figure 8-3. Setadd(element) adaptee Hashtableput(key,element) MySet add(element)Client

10 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 10 Figure 8-7, Applying the Bridge design pattern for abstracting database vendors. LeagueStoreImplementorLeagueStore imp XML Store Implementor Stub Store Implementor JDBC Store Implementor Arena

11 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 11 Figure 8-8, Applying the Adapter design pattern for sorting Strings in an Array. See source code in Figure 8-9. Comparatorcompare() adaptee MyString MyStringComparator compare() greaterThan() equals() Array

12 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 12 Figure 8-9, Adapter design pattern example. /* Existing target interface */ interface Comparator { int compare(Object o1, Object o2); /*... */ } /* Existing client */ class Array { static void 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 } else if (o1.equals(o2)) { result = 0; } else { result = -1; } return result; }

13 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 13 Figure 8-10, Applying the Strategy pattern for encapsulating multiple implementations of a NetworkInterface. NetworkInterface open() close() send() receive() NetworkConnection send() receive() setNetworkInterface() LocationManagerApplication Ethernet open() close() send() receive() WaveLAN open() close() send() receive() UMTS open() close() send() receive()

14 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 14 Figure 8-12, Applying the Abstract Factory design pattern to different intelligent house platforms HouseFactory LightBulb EIBBulbLuxmateBulb LuxmateFactory EIBFactory createBulb() createBlind() Blind EIBBulbLuxmateBulb TheftApplication createBulb() createBlind() createBulb() createBlind()

15 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 15 Figure 8-13, Applying the Command design pattern to Matches in ARENA. GameBoard «binds» TicTacToeMove execute() ChessMove execute() Move execute() Match * replay() play()

16 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 16 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. Top panel Main panel Button panel

17 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 17 Figure 8-15, UML object diagram for the user interface objects of Figure 8-14. top:Panel prefs:Window ok:Button main:Panelbuttons:Panel title:Label c2:Checkbox c3:Checkbox c4:Checkbox cancel:Button c1:Checkbox

18 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 18 Figure 8-16, Applying the Composite design pattern to user interface widgets. Component * CheckboxButtonCompositeLabel Panel Window Applet move() resize() move() resize()

19 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 19 Figure 8-17, An example of dynamic site with WebObjects. WebBrowser RelationalDatabase StaticHTML WOAdaptor WebServer WoRequest Template WebObjectsApplication WORequest EOF

20 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 20 Figure 8-18, WebObject’s State Management Classes. The HTTP protocol is inherently stateless. WOSessionWOComponentDynamicElement WOApplication WORequest WOAdaptor * * * * WebServerWOSessionStore *

21 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 21 Figure 8-19, ARENA analysis objects related to Game independence. League TournamentMatch GameArena LeagueOwnerPlayerMoveResult Statistics TicTacToe Chess

22 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 22 Figure 8-20, Applying the Abstract Factory pattern to Games Game Match TTTMatchChessMatch Chess TicTacToe createBulb() createBlind() Statistics TTTStatsChessStats Tournament createMatch() createStatistics() createBulb() createBlind()

23 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 23 Figure 8-21, Applying the Command design pattern to Matches and ReplayedMatches in ARENA. replay() «binds» play() TicTacToeMoveChessMove Move execute() Match * GameBoard nextMove() ReplayedMatch previousMove()

24 Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 24 Figure 8-22, Applying the Observer design pattern to maintain consistency across MatchViews. GameBoard state getState() playMove() Observer update() MatchView gameBoard update() observers * 1 Subject subscribe(Subscriber) unsubscribe(Subscriber) notify()


Download ppt "Using UML, Patterns, and Java Object-Oriented Software Engineering Art for Chapter 8, Object Design: Reusing Pattern Solutions."

Similar presentations


Ads by Google