Tài liệu Class & object diagrams - software design methodology

  • Số trang: 36 |
  • Loại file: PDF |
  • Lượt xem: 60 |
  • Lượt tải: 0
nguyen-thanhbinh

Đã đăng 10809 tài liệu

Mô tả:

Class & Object Diagrams Software Design Methodology UML Class Diagrams The heart of the UML „ Describes the classes in the system and the relations among them „ Supports most OO concepts „ … associations … aggregation … inheritance (including multiple) 2 Classes „ Classes are denoted by rectangles. ‹Attributes ‹Operations ‹Responsibilities Class attribute: type operation operation(parameters) responsibility 3 Classes Attribute: A named property of a class that describes a range of values that instances of the property may hold. „ Operation: Implementation of a service that can be requested. „ Responsibility: A contract or an obligation of a class. As the model is refined the responsibilities are transformed into attributes and operations. „ 4 Object • Object - a concept, an abstraction, a thing meaningful to the domain • • • • Joe Smith Lassie flight #713 the top window Person Dog Flight Window • Object Class - a collection of all objects having the same set of features. • Each object has a unique identity and is an instance of its object class. 5 Class Diagrams vs. Object Diagrams p:Person Person name employeeID title name=“Yahoo” employeeID=1212 title=“VP of production” Joe Smith:Person 6 Relationships A relationship is a connection among things. „ Common relationships: Dependencies, Associations, Generalization and Aggregations. „ 7 Dependency „ A dependency states that a change in specification of one thing may effect another thing that uses it CourseSchedule A class takes an object of another class as a parameter add(c:Course) Course remove(c:course) Window open() A class accesses an object of another class Event close() Student grade CalculateAverage(grade) A class calls a class operation in another class Dean 8 Association An association is structural relationship that specifies that objects of one thing are connected to objects of another. Binary association City Country Name: string Population: integer Area: Km2 Has-capital Name: string Population: integer 9 Association Name „ Printed at the center of the line „ Describes the nature of the relationship (usually a verb) „ A direction triangle can be added 10 Association Multiplicity Used when it is important to state how many objects may be connected across an instance of an association. „ When a number is stated at an end of an association it is specified that for each object at the class at the opposite end there must be that many objects at the near end. „ An * denotes many - which can be any number between zero and infinity. „ 11 Multiplicity Example 1..* Employee 1 Department 1..10 0..1 Office At least one employee in a department An employee belongs to exactly one department An employee has zero or one office An office is assigned to a number of one up to 10 employees 12 Multiplicity symbols (participation constraints) Line Name: string 0,2..* * Intersects * Point Is Endpoint Of 2 Name: string X-Coordinate: integer Y-Coordinate: integer 13 Association Classes Denoted as a class attached to the association „ Specify properties of the association „ Does not belong to any of the connected class „ Car * Reg. Num. Model Year Owner of Year Purchased 1.. * Person Name 14 Association Attributes Person Name: string ID: string Address: string Student Name ID Faculty Company 1..* Works-for * Name: string Address: string salary: float job: string 140 submit Grade Assignment 4 Number Subject Submission date 15 Association Role Names Names may be added at each end of the association „ Provide better understanding of the association meaning „ Especially helpful in self-associated classes „ Worker * Manages *..1 Person employee * employer Company 1..0 Manager 16 Role Names, Constraints and Qualifiers Role 1 owner * 0..1 authorized user User * * Directory container * contents Ordering Window * {ordered} 1 visible-on Screen Qualifier: an attribute that reduces the association’s multiplicity. Directory file name * 0..1 File 17 Classes versus Objects Class Diagram Classes name attributes operations responsibility Association name multiplicity role Association Classes Object Diagram Objects values for attributes Link Link Object 18 Class Diagram Example Reader Name ID Address 0..1 holds * Code Shelf location Status Loan duration Return date * {ordered} Copy * reserved * Book 1 of Code Name Edition Author 19 Object Diagram Example 357:Reader Name=“Joe” ID=357 Address=“Jerusalem” 482:Reader Name:”Michel” ID=482 Address=“Haifa” holds 57168-1:Copy Return date=16.11.00 holds 57168-2:Copy Return date=24.11.00 936:Reader Name=“David” ID=936 Address=“Haifa” reserved Code=57168-1 Shelf location=681.3.06 Status=“at loan” Loan duration=2 weeks Code=57168-2 Shelf location=681.3.06 Status=“at loan” Loan duration=1 month UML:Book Code=57168 Name=“The Unified Modeling Language User Guide” Edition=1 Author=“Booch, Rumbaugh, Jacobson” of of 20
- Xem thêm -