100 likes | 222 Vues
Object-Oriented Design (OOD) involves planning the necessary components or classes for a system, determining their roles and relationships to model the system before implementation. Using modeling techniques, such as UML (Unified Modeling Language), helps visualize the system structure, making it easier for developers to coordinate efforts. Key diagram types include class diagrams, use cases, and interaction diagrams. Class diagrams specifically depict classes, their attributes and methods, and relationships like inheritance, composition, and association, enhancing understanding and collaboration within development teams.
E N D
OO Design • Planning the components (classes) necessary for a system • Determine: • the classes that will be defined • their roles and relationships (and interaction) with each other • Modeling
Why Go Through Design? • Modeling a system before implementing (coding) saves time and increases the chances of success • Can worry less about programming details • The design model serves as a coordination point between programmers in a team
Modeling Techniques • Notation • The UML: Unified Modeling Language • The Standard for OO Systems • Diagramming Techniques in the UML • Class Diagrams • Use Cases • Interaction Diagrams • Others
Class Diagrams • What is Depicted? • Classes • name, attributes, methods • rectangles • Relationships • inheritance, composition, association • links
Classes in a Class Diagram • Class name only Example • With Details Example Ledger Class Name Ledger double balance post() sortByDate() Class Name attributes methods
Relationships • Inheritance (arrow) • example: between Secretary and Employee • Composition/Aggregation (diamond) • example: between Car and Wheel • Association (line) • example: between Borrower and Book
Inheritance Employee public class Secretary extends Employee { … } Secretary
Composition Car Wheel 4 w[] public class Car { Wheel w[]; ... public Wheel() { w = new Wheel[4]; … } ... }
Association Borrower Book 1 3 currBorr bk[] public class Borrower { Book bk[]; … public Borrower() { bk = new Book[3]; } } public class Book { Borrower currBorr; … }