Unformatted text preview:

Using UML Patterns and Java Object Oriented Software Engineering Chapter 8 Object Design Reuse and Patterns II Outline of the Lecture Design Patterns Usefulness of design patterns Design Pattern Categories Patterns covered in this lecture Composite Model dynamic aggregates Facade Interfacing to subsystems Adapter Interfacing to existing systems legacy systems Bridge Interfacing to existing and future systems Patterns covered in the next lecture Abstract Factory Proxy Command Observer Strategy Bernd Bruegge Allen H Dutoit Object Oriented Software Engineering Using UML Patterns and Java 2 Finding Objects The hardest problems in object oriented system development are Identifying objects Decomposing the system into objects Requirements Analysis focuses on application domain Object identification System Design addresses both application and implementation domain Subsystem Identification Object Design focuses on implementation domain Additional solution objects Bernd Bruegge Allen H Dutoit Object Oriented Software Engineering Using UML Patterns and Java 3 Techniques for Finding Objects Requirements Analysis Start with Use Cases Identify participating objects name of the Textual analysis of flow of events find nouns verbs technique Extract application domain objects by interviewing client application domain knowledge Find objects by using general knowledge System Design Subsystem decomposition Try to identify layers and partitions What s the difference Object Design Find additional objects by applying implementation domain knowledge Bernd Bruegge Allen H Dutoit Object Oriented Software Engineering Using UML Patterns and Java 4 Another Source for Finding Objects Design Patterns What are Design Patterns A design pattern describes a problem which occurs over and over again in our environment Then it describes the core of the solution to that problem in such a way that you can use the this solution a million times over without ever doing it the same twice Bernd Bruegge Allen H Dutoit Object Oriented Software Engineering Using UML Patterns and Java 5 Notation used in the Design Patterns Book Erich Gamma Richard Helm Ralph Johnson John Vlissides Design Patterns Elements of Reusable Object Oriented Software Addison Wesley 1995 Based on OMT Notation a precursor to UML Notational differences between the notation used by Gamma et al and UML In Gamma et al Attributes come after the Operations Associations are called acquaintances Multiplicities are shown as solid circles Dashed line Instantiation Assocation Class can instantiate objects of associated class In UML it denotes a dependency UML Note is called Dogear box connected by dashed line to class operation Pseudo code implementation of operation See Google Scholar But has this been validated and agreed upon by Bernd Bruegge Allen H Dutoit Object Oriented Software Engineering Using UML Patterns and Java 6 Introducing the Composite Pattern Models tree structures that represent part whole hierarchies with arbitrary depth and width The Composite Pattern lets client treat individual objects and compositions of these objects uniformly Component Client Leaf Operation Is this a good model Bernd Bruegge Allen H Dutoit Composite Operation AddComponent RemoveComponent GetChild Object Oriented Software Engineering Using UML Patterns and Java Children 7 Graphic Applications also use Composite Patterns The Graphic Class represents both primitives Line Circle and their containers Picture Graphic Client Line Draw Is this a good model Bernd Bruegge Allen H Dutoit Circle Draw Picture Draw Add Graphic g RemoveGraphic GetChild int Object Oriented Software Engineering Using UML Patterns and Java Children 8 Adapter Pattern Convert the interface of a class into another interface clients expect The adapter pattern lets classes work together that couldn t otherwise because of incompatible interfaces Used to provide a new interface to existing legacy components Interface engineering reengineering Also known as a wrapper Two adapter patterns Class adapter Uses multiple inheritance to adapt one interface to another Object adapter Uses single inheritance and delegation Object adapters are much more frequent We will only cover object adapters and call them therefore simply adapters Bernd Bruegge Allen H Dutoit Object Oriented Software Engineering Using UML Patterns and Java 9 Adapter pattern Client ClientInterface LegacyClass Request ExistingRequest adaptee Adapter Request Delegation is used to bind an Adapter and an Adaptee What would the body of Request be like Interface inheritance is use to specify the interface of the Adapter class Target and Adaptee usually called legacy system pre exist the Adapter Target may be realized as an interface in Java Bernd Bruegge Allen H Dutoit Object Oriented Software Engineering Using UML Patterns and Java 10 Bridge Pattern Use a bridge to decouple an abstraction from its implementation so that the two can vary independently From Gamma et al 1995 Also know as a Handle Body pattern Allows different implementations of an interface to be decided upon dynamically Bernd Bruegge Allen H Dutoit Object Oriented Software Engineering Using UML Patterns and Java 11 Using a Bridge The bridge pattern is used to provide multiple implementations under the same interface Examples Interface to a component that is incomplete not yet known or unavailable during testing JAMES Project if seat data is required to be read but the seat is not yet implemented known or only available by a simulation provide a bridge VIP Seat in Vehicle Subsystem GetPosition SetPosition Stub Code Bernd Bruegge Allen H Dutoit imp AIMSeat Object Oriented Software Engineering Using UML Patterns and Java SeatImplementation SARTSeat 12 Seat Implementation public interface SeatImplementation public int GetPosition public void SetPosition int newPosition public class Stubcode implements SeatImplementation public int GetPosition stub code for GetPosition public class AimSeat implements SeatImplementation public int GetPosition actual call to the AIM simulation system public class SARTSeat implements SeatImplementation public int GetPosition actual call to the SART seat simulator Bernd Bruegge Allen H Dutoit Object Oriented Software Engineering Using UML Patterns and Java 13 Bridge Pattern Client imp Abstraction Implementor Operation OperationImpl Imp OperationImp Ref ned Abstraction 1 Ref ned Abstraction 2 Concrete Implementor A Concrete Implementor B Operation Operation OperationImpl


View Full Document

UTD CS 6354 - Chapter 8- Object Design Reuse and Patterns II

Loading Unlocking...
Login

Join to view Chapter 8- Object Design Reuse and Patterns II and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Chapter 8- Object Design Reuse and Patterns II and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?