Presentation is loading. Please wait.

Presentation is loading. Please wait.

Class Diagram Lecture # 1. Class diagram A Class Diagram is a diagram describing the structure of a system shows the system's classes Attributes operations.

Similar presentations


Presentation on theme: "Class Diagram Lecture # 1. Class diagram A Class Diagram is a diagram describing the structure of a system shows the system's classes Attributes operations."— Presentation transcript:

1 Class Diagram Lecture # 1

2 Class diagram A Class Diagram is a diagram describing the structure of a system shows the system's classes Attributes operations (or methods), Relationships among the classes.

3 Class Diagram Class diagrams represent the static elements of a system, rather than processes and describe the classes, the data and functionality they contain and the relationships between them.

4 Example A class is a description of a set of objects that share the same attributes, operations, relationships. Graphically, a class is rendered as a rectangle, usually including its name, attributes, and operations in separate, designated compartments ClassName attributes operations

5 Attributes An attribute is a named property of a class that describes the object being modeled. In the class diagram, attributes appear in the second compartment just below the name- compartment. Person name : String address : Address birthdate : Date

6 12/2/2014 Derived Attribute Attributes are usually listed in the form: attributeName : Type A derived attribute is one that can be computed from other attributes, but doesn’t actually exist. For example, a Person’s age can be computed from his birth date. A derived attribute is designated by a preceding ‘/’ as in: / age : Date Person name : String address : Address birthdate : Date / age : Date

7 Class Attributes Attributes can be: + public # protected - private / derived Person + name : String # address : Address # birthdate : Date / age : Date

8 Activity Diagram Symbols Operations describe the class behavior and appear in the third compartment. Person name : String address : Address birthdate : Date eat sleep work play

9 Relationships in classes Association Aggregation Composition Dependency Generalization

10 Association If two classes in a model need to communicate with each other, there must be link between them. An association denotes that link. An association between two classes indicates that objects at one end of an association “recognize” objects at the other end and may send messages to them. Student Instructor instructs Here, an association is instructs

11 Association Relationships(Cont’d) We can indicate the multiplicity of an association by adding multiplicity adornments to the line denoting the association. The example indicates that a Student has one or more Instructors: Instructor Student 1..*

12 Associations (cont.) Multiplicity the number of objects that participate in the association. Indicates whether or not an association is mandatory. Exactly one1 Zero or more (unlimited)* (0..*) One or more1..* Zero or one (optional association)0..1 Specified range2..4 Multiplicity Indicators

13 UML Class Diagrams 13 Associations (cont.) StaffMemberStudent 1..**instructs instructor Association name Role name Multiplicity Navigable (uni-directional) association Courses pre - requisites 0..3 Reflexive association Role *

14 Qualified Association A qualified association associates two objects using a qualifier to select objects at the other end of the association. A qualifier is an attribute or set of attributes which has a unique value for each object in the class.

15 Aggregation Aggregation is a relationship where one class is part of another class. In basic aggregation, the class that forms part of the whole class can exist independently, so the life of an instance of the part class is not determined by the whole class. Basic aggregation is represented using an empty diamond symbol next to the whole class.

16 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. Whole Part Car Door House 1..*2..*

17 Aggregation

18 Composition Composition is a strong type of aggregation where the whole class contains the instance of the part class. The lifetime of the part class depends on the existence of the whole class. Composition relationships are represented using a filled diamond symbol next to the whole class

19 Composition A strong form of aggregation The whole is the sole owner of its part. The part object may belong to only one whole Multiplicity on the whole side must be zero or one. The life time of the part is dependent upon the whole. The composite must manage the creation and destruction of its parts.

20 Generalization A generalization connects a subclass to its superclass. It denotes an inheritance of attributes and behavior from the superclass to the subclass and indicates a specialization in the subclass of the more general superclass. Person Student

21 Generalization Relationships (Cont’d) Student UML permits a class to inherit from multiple superclasses, although some programming languages (e.g., Java) do not permit multiple inheritance. TeachingAssistant Employee

22 Generalization The inheritance relationship, also known as the generalization relationship, is used to indicate that one class is a specialization of another. Shape {abstract} Circle Super Class Sub Class An abstract class Generalization relationship {abstract} is a tagged value that indicates that the class is abstract. The name of an abstract class should be italicized

23 Dependency Dependency is a weaker form of relationship which indicates that one class depends on another because it uses it at some point in time. CourseSchedule add(c : Course) remove(c : Course) Course

24 Class diagram

25 Registration

26 Class Diagram


Download ppt "Class Diagram Lecture # 1. Class diagram A Class Diagram is a diagram describing the structure of a system shows the system's classes Attributes operations."

Similar presentations


Ads by Google