class diagram n.
Skip this Video
Loading SlideShow in 5 Seconds..
Class Diagram PowerPoint Presentation
Download Presentation
Class Diagram

Class Diagram

20 Vues Download Presentation
Télécharger la présentation

Class Diagram

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Class Diagram Tutorial 5

  2. diagramsUML *Communication diagram(Collaboration diagram)

  3. Class Diagram • A Class diagram is used to display some of the classes and packages in your system • It gives you a static picture of the pieces in the system and of the relationships between them • They help the developers see and plan the structure of the system before the code is written, helping to ensure that the system is well designed from the beginning

  4. Class Specifications • Class Name - Unique Name, No spaces, Short, Starting with an upper-case letter • Class Visibility • Public - the class can be seen by all of the other classes in the system • Protected or private - the class can be seen in nested classes • Class Multiplicity - The number of instances that you expect to have of a class • Storage Requirements for a Class - The amount of memory you expect each object of the class to require

  5. Class Specifications cont. • Class Persistence • Persistent – the information in objects of the class will be saved to a database or some other form of persistent storage. • Transient –the information in objects of the class will not be saved to persistent storage.

  6. Class Attributes Specifications • Data Type (e.g. string, double, int, etc..) • Initial Value – Not required • Visibility • Public - the attribute is visible to all other classes ( + ) • Private - the attribute is not visible to any other class (- ) • Protected - the class and any of its descendants have access to the attribute (#)

  7. Class Attributes Specifications cont. • Containment • By Value - the attribute is contained within the class • Reference - the attribute is located outside the class, but theclass has a pointer to it • Static Attribute - Shared by all instances of the class • Derived Attribute - Created from other attributes , Ex. Area is created from the height and width attributes

  8. Class Operations • An operation is a behavior associated with a class • An operation has three parts: • The Operation Name • The Operation Parameters • The Operation Return Type • The parameters are arguments the operation receives as input. The return type is the output of the operation.

  9. Relationships between classes Class A Superclass Class with parts name Class B Subclass Assembly Class Association (relationship) Inheritance (Generalization) (is-a, kind-of) Aggregation (Part-Of)

  10. Associations • A semantic relationship between two or more classes that specifies connections among their instances • Example: “An Employee works for a Company”

  11. Generalization or Inheritance • Indicates that objects of the specialized class (subclass) are substitutable for objects of the generalized class (super-class) • “is kind of” relationship An abstract class Shape Super Class Generalization relationship Sub Class Circle

  12. Generalization • A sub-class inherits from its super-class • Attributes • Operations • Relationships • A sub-class may • Add attributes and operations • Add relationships • Refine (override) inherited operations

  13. Car Aggregation • A special form of association that models a whole-part relationship between an aggregate (the whole) and its parts. • Models a “is a part-part of” relationship. 4 Wheel wheels Whole Part

  14. Head Arm Person Class Student Basic Class Diagram (Example) takes

  15. Example

  16. Practice

  17. Case study • A company database keeps track of a company's EMPLOYEES, DEPARTMENTS, PROJECTS, and the DEPENDENTS of employees. Each department has a unique name, a unique number, and a particular employee who manages the department. We keep track of the start date when the employee began managing the department. A department may have several locations. A department controls a number of projects, each of which has a unique name, and a single location. We store each employee's name, social security number, address, salary, sex, and birth date. An employee is assigned to one department but may work on several projects, which are not necessarily controlled by the same department. We keep track of the number of hours per week that an employee works on each project. We also keep track of the direct supervisor of the employee. We want to keep track of the dependents of each employee. We keep each dependent's name, sex, birth-date, and relationship to the employee. Model DEPENDENT as a class that has ID dependency on EMPLOYEE.