310 likes | 324 Views
Understand the essential concepts and practices of object-oriented analysis and design using UML. Learn to refine analysis relationships, design classes, and translate analysis into design effectively. Explore design workflows and create well-structured designs.
E N D
Part V: Design The Design Workflow Design Classes Refining Analysis Relationships Object Oriented Analysis & Design & UML (Unified Modeling Language)
Content • The Design Workflow • Design Classes • Refining Analysis Relationships Object Oriented Analysis & Design & UML (Unified Modeling Language)
The Design Workflow Object Oriented Analysis & Design & UML (Unified Modeling Language)
Unified Process - Overview • Design is muchmoreconsentrated in • ElaborationandConstructionphases Object Oriented Analysis & Design & UML (Unified Modeling Language)
Design Model • The design modelcontains • exactly one design system • that contains many design subsystems Object Oriented Analysis & Design & UML (Unified Modeling Language)
From Analysis to Design • there is a simple one-to-one «trace» relationship • between the analysis system • and the design system • the design model • is based on the analysis model, • can be consideredto be • just a refinement and elaboration of analysis model Object Oriented Analysis & Design & UML (Unified Modeling Language)
Design Workflow • Artefacts • Designsubsystems • Designclasses • DesignInterfaces • Usecaserealizationsfordesign Object Oriented Analysis & Design & UML (Unified Modeling Language)
Analysis Class-Design Class • An analysis class may be resolved into • one or more interfaces • or designclasses. • analysis classes are • a high-level conceptual view ofthe classes in the system. Inphysical modeling (design): • conceptual classesareimplemented as • one or moredesign classes • and/or interfaces Object Oriented Analysis & Design & UML (Unified Modeling Language)
Tracing Analysis to Design • Eachanalysisclass • can be tracedto • multipledesignclasses/interfaces Object Oriented Analysis & Design & UML (Unified Modeling Language)
What are Design Classes? • Classes with completed definition • Detailed so that ready to implement • Sources of design classes • Problem domain • via refinement of analysis classes • Solution domain • Utility classes • Time, Date, String, collections, … • Middleware • Communications, database,.. • Component frameworks • DCOM, CORBA, Enterprise JavaBeans • GUI Framework • Window, Form, Button, Menu, … Object Oriented Analysis & Design & UML (Unified Modeling Language)
Translating Analysis Classes into Design Classes • Refine analysis class • into one or more design classes • if classes become too large • design level abstraction is more detailed • add newly found attributes • to make the class complete for implementation • new implementation level attributes • Broke large analysis classes • into two or more classes • Good design classes must be • Small • Self-contained • Cohesive units Object Oriented Analysis & Design & UML (Unified Modeling Language)
Anatomy of Design Class • Specify how the class • will fulfill its responsibilities • Complete list of attributes • Fully specify with • visibility, name, type, • Default values (if there are any) • Complete set of methods • visibility, name, parameter list, type, • return value Object Oriented Analysis & Design & UML (Unified Modeling Language)
Example: BankAccount Object Oriented Analysis & Design & UML (Unified Modeling Language)
Inheritance • In analysis • use inheritance to implement “is a” relationships • In design • use inheritance to reuse code as well • Inheritance is • Strongest for coupling • Changes to parent classes • have a large impact on classes in the hierarchy • Encapsulation is weak in class hierarchy • Child classes can access to base’s attributes! • Inflexible • Fixed at run-time • You cannot change it as done in aggregation Object Oriented Analysis & Design & UML (Unified Modeling Language)
Aggregation instead of Inheritance (?) • subclass • always represents “is kind of” • not “is role played by” • john: • changesthe role • by just changing link between role and:Programmer Object Oriented Analysis & Design & UML (Unified Modeling Language)
Multiple Inheritance • Some OO Languages do not allow • Languages do not support: Java, C# • Language supports : C++ • Overlap between the classes • causes unforeseen interactions • “is kind of” and substitutability principles must apply • common parents cause • Multiple occurrence of the same features Object Oriented Analysis & Design & UML (Unified Modeling Language)
Aggregation • Whole-part relationship • A lose relationship • Whole does not own the parts • Parts • Created and destructed any time • are not dependent on the whole • Example: • Computer system and the peripherals Object Oriented Analysis & Design & UML (Unified Modeling Language)
Aggregation Rules • The aggregate can exist • independent from its parts • The parts can exist • independent from the aggregate • The aggregate is incomplete • If the parts are missing • The same parts • can be shared by multiple aggregates Object Oriented Analysis & Design & UML (Unified Modeling Language)
Composition • A whole-part relationship • Strong type of relationship • The life cycle of the parts depend on the whole • Parts • can be created • only after the whole is created • destructed by default • when the whole is destructed • Example: • Tree and its leaves Object Oriented Analysis & Design & UML (Unified Modeling Language)
Composition Rules • The parts • belong to only one composite • cannot exist without the composite • The composite • creates and destroys the parts Object Oriented Analysis & Design & UML (Unified Modeling Language)
Aggregation vs Composition • Aggregation • a Computer may be attched to • 0 or more Printers • at any time a Printer is connected to • 0 or more Computers • over time a computer may • use a given Printer • the printer exist • even if there are no Computers attached • the Printer is • independent from the Computer • Composition • a Tree might have • 0 or many Leaves at a time • over time a computer may use a given Printer • Tree still exist even if it has no Leaves at all • the Leaves cannot exist without the Tree • the Leaves are dependent on the Tree Object Oriented Analysis & Design & UML (Unified Modeling Language)
How to Refine Analysis Relationships? • Add multiplicities and role names • to associations • if they were absent • Decide which of the side is whole • and which side is the part • Look at the whole side • If it is exactly 1: • You may apply the composition • Otherwise • You must set it as aggregation • Add navigability from the whole to the part • Design associations must be unidirectional! • Decide how to implement • the multiplicities greater than 1 • on both sides Object Oriented Analysis & Design & UML (Unified Modeling Language)
One-to-One Associations • One-to-one associations become composition Object Oriented Analysis & Design & UML (Unified Modeling Language)
Many-to-one Associations • Many on the whole side: • Use aggregation • You cannot use composition • Reason: the whole cannot be shared in composition! Object Oriented Analysis & Design & UML (Unified Modeling Language)
One-to-Many Associations • There are collection of objects • on the parts side • Use collections • to implement • If the language does not support collections • Use arrays • Implement collections Object Oriented Analysis & Design & UML (Unified Modeling Language)
Implementation of one-to-many • If life-cycle of the parts • is dependent on the whole • Use aggregation • Otherwise use composition Object Oriented Analysis & Design & UML (Unified Modeling Language)
Specification of Parts’ Semantics Object Oriented Analysis & Design & UML (Unified Modeling Language)
Many-to-Many Relationships • commonly used OO languages does not support • Many-to-Many relationships • Add new design class between Object Oriented Analysis & Design & UML (Unified Modeling Language)
End of Chapter Object Oriented Analysis & Design & UML (Unified Modeling Language)