Presentation is loading. Please wait.

Presentation is loading. Please wait.

COP 3330 Notes 4/13. Today’s Topics UML Class Diagrams.

Similar presentations


Presentation on theme: "COP 3330 Notes 4/13. Today’s Topics UML Class Diagrams."— Presentation transcript:

1 COP 3330 Notes 4/13

2 Today’s Topics UML Class Diagrams

3 UML stands for Unified Modeling Language There are many types of diagrams specified by UML, but we'll only focus on class diagrams UML class diagrams depict structural relationships among classes

4 UML Class Diagrams A class is represented as a rectangle subdivided into three areas Example: Simplified Student class

5 UML Class Diagrams A field is specified with its access modifier first, then its name, then a :, then the type –e.g. on the previous slide, the Java code equivalent of the field would be private double gpa;

6 UML Class Diagrams A method is specified with access modifier first, then its name, then its formal parameters in parentheses, then a :, then its return type –e.g. the Java code equivalent of the method header would be public void setGPA(double newgpa)

7 UML Class Diagrams Access modifiers: The visibility of fields and methods are represented by the first character before their names –Private: - –Public: + –Protected: #

8 UML Class Diagrams Other modifiers: –If a method or field is underlined that indicates that it is static –If a method, field, or class name is italicized, that indicates that it is abstract

9 UML Class Diagrams Relationships among classes –Generalization (extends in Java) –Realization (implements in Java) Arrow with dashed line allows details of the interface to be specified Lollipop does not

10 UML Class Diagrams Relationships among classes –Aggregation: One type of has-a relationship Indicates weak life-cycle dependence e.g. an AcademicDepartment can be destroyed, yet its Students live on –Composition: Another type of has-a relationship Indicates strong life-cycle dependence e.g. When a car is destroyed, so is its engine

11 UML Class Diagrams Relationships among classes –Pretty much any other relationship is association

12 UML Class Diagrams Example: Extremely simplified class diagram of Assignment 3 (fields and methods omitted for clarity)


Download ppt "COP 3330 Notes 4/13. Today’s Topics UML Class Diagrams."

Similar presentations


Ads by Google