Information about CLASS DIAGRAMS

Published on April 26, 2008

Author: tallurijkumar



CLASS DIAGRAMS : CLASS DIAGRAMS JAGADISH & JOHN Slide 2: UML Class Diagrams 2 WHY? HOW? WHEN? WHAT? WHY? : UML Class Diagrams 3 WHY? Clarity in understanding the system requirements. Better communication. Model driven architecture. Designing data base. Code generation. Reverse engineering. Helps to develop a good software. WHAT? : UML Class Diagrams 4 WHAT? A pictorial/graphical representation of Names Properties Actions Relationships WHEN? : UML Class Diagrams 5 WHEN? In a software development life cycle model, We have… REQUIREMENTS DESIGN IMPLEMENTATION TESTING UML Slide 6: UML Class Diagrams 6 HOW? Agenda : UML Class Diagrams 7 Agenda What is a Class Diagram? Essential Elements of a UML Class Diagram Tips Development of class diagram from a use case diagram What is a Class Diagram? : UML Class Diagrams 8 What is a Class Diagram? A class diagram describes the types of classes in the system and the various kinds of static relationships that exist among them. A central modeling technique that runs through nearly all object-oriented methods. The richest notation in UML. Essential Elements of a UML Class Diagram : UML Class Diagrams 9 Essential Elements of a UML Class Diagram Class Attributes Operations Relationships Associations Generalization Dependency Realization Constraint Rules and Notes Classes : UML Class Diagrams 10 Classes A class is the description of a set of objects having similar attributes, operations, relationships and behavior. Class Name Attributes Operations Associations : UML Class Diagrams 11 Associations A semantic relationship between two or more classes that specifies connections among their instances. A structural relationship, specifying that objects of one class are connected to objects of a second (possibly the same) class. Example: “An Employee works for a Company” Associations (cont.) : UML Class Diagrams 12 Associations (cont.) Staff Member Student 1..* * instructs instructor Association name Role name Multiplicity Associations (cont.) : UML Class Diagrams 13 Associations (cont.) Multiplicity The number of instances of the class, next to which the multiplicity expression appears, that are referenced by a single instance of the class that is at the other end of the association path. It indicates how many objects of one class relate to one object of another class. Provides a lower and upper bound on the number of instances. Slide 14: UML Class Diagrams 14 Code replacement of Association. Associations (cont.) : UML Class Diagrams 15 Associations (cont.) Multiplicity Indicators Visibility : UML Class Diagrams 16 Visibility Private members can only be referenced in the same class where they are declared.(-) Protected members can be referenced in the same class or any descendants of that class.(#) Package scope members can be referenced by any classes in the same UML package only.(~) Public members can be referenced directly by any class( in the same or other package).(+) SHOWING VISIBILITY : UML Class Diagrams 17 SHOWING VISIBILITY class name +attribute1 -attribute2 #operation1(): ~operation2(): Aggregation : UML Class Diagrams 18 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 Aggregation (cont.) : UML Class Diagrams 19 Aggregation (cont.) In an aggregation the part classes can exist without the whole. When the part classes are destroyed, the whole class will continue to exist. When the whole class is destroyed, the part classes will still exist. Aggregation tests: Is the phrase “part of” used to describe the relationship? A door is “part of” a car Are some operations on the whole automatically applied to its parts? Move the car, move the door. Are some attribute values propagated from the whole to all or some of its parts? The car is blue, therefore the door is blue. Composition : UML Class Diagrams 20 Composition A strong form of aggregation The part classes used to make up the whole class cannot exist on their own. Multiplicity on the whole side must be zero or one. The life time of the part is dependent upon the whole. The destruction of the whole class means destruction of the part classes. 0..* 1..* Generalization : UML Class Diagrams 21 Generalization Indicates that objects of the specialized class (subclass) are substitutable for objects of the generalized class (super-class). “is kind of” relationship. Generalization : UML Class Diagrams 22 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 Slide 23: UML Class Diagrams 23 Code replacement of Generalization. Dependency : UML Class Diagrams 24 Dependency A dependency indicates a semantic relation between two or more classes in which a change in one may force changes in the other although there is no explicit association between them. Course schedule +add(c:Course):void +remove(c:Course):void Course Slide 25: UML Class Diagrams 25 Code replacement of Dependency. Realization : UML Class Diagrams 26 Realization A realization relationship indicates that one class implements a behavior specified by another class (an interface or protocol). An interface can be realized by many classes. A class may realize many interfaces. class <<interface>> Slide 27: UML Class Diagrams 27 Code replacement of Realization. Constraint Rules and Notes : UML Class Diagrams 28 Constraint Rules and Notes Constraints and notes annotate among other things associations, attributes, operations and classes. UML offers many pre-defined constraints. Constraint Note Tips : UML Class Diagrams 29 Tips Don’t try to use all the various notations. Don’t draw models for everything, concentrate on the key areas. Draw implementation models only when illustrating a particular implementation technique. LET’S SEE ACASE STUDY : UML Class Diagrams 30 LET’S SEE ACASE STUDY Slide 31: UML Class Diagrams 31 distribute electronically record grades update grades logon view grades generate report cards save grades load grades << include >> << include >> << include >> << include >> teacher administrator student A typical use case diagram…. Learn how to model a class diagram : UML Class Diagrams 32 Learn how to model a class diagram Finding classes and their associations. Finding attributes and operations. First identify all the nouns. (here we have Grades and ReportCard) Second identify all the actors. (here we have teacher, student and administrator) Now we have to create a home for the use cases : UML Class Diagrams 33 Now we have to create a home for the use cases Distribute Report Cards – Grade Class Record Grades – Grade Class Update Grades – Grade Class Save Grades – Grade Class Load Grades – Grade Class Logon - ? View Grades – Grade Class Generate Report Cards – Report Card Class Now relationships : UML Class Diagrams 34 Now relationships A Teacher distributes the Grades A Teacher records the Grades A Teacher updates the Grades A Grade will save itself A Grade will load itself A Teacher views Grades An Administrator views Grades An Administrator generates Report Cards A Student views Grades After consolidation : UML Class Diagrams 35 After consolidation A Teacher maintains Grades A Teacher views Grades An Administrator views Grades An Administrator generates Report Cards A Student views Grades Slide 36: UML Class Diagrams 36 Teacher Grades ReportCard WebSite Logon Administrator Student maintains > < contains ^ displays uses > uses > < uses ^ generates Now multiplicity : UML Class Diagrams 37 Teacher Grades ReportCard WebSite Administrator OnlineUser maintains > < contains ^ displays uses > ^ generates Now multiplicity 1 1..* 1..* 1..* 1 1 Slide 38: UML Class Diagrams 38 Teacher Grades ReportCard WebSite Administrator OnlineUser ^ displays uses > ^ generates 1 1..* 1..* 1..* 1 1 +RecordGrades() +UpdateGrades() +Distribute() -SaveGrades() -LoadGrades() maintains > +Generate() +Logon() +View() Slide 39: UML Class Diagrams 39 Teacher Grades ReportCard WebSite Administrator OnlineUser ^ displays uses > ^ generates 1 1..* 1..* 1..* 1 1 +RecordGrades(Student:String,Assignment:String,Grade:Integer) +UpdateGrades(Student:String,Assignment:String,Grade:Integer) +Distribute() -SaveGrades() -LoadGrades() maintains > +UserName:String +Password:String +Logon() +View() < contains +Generate() THANK YOU : UML Class Diagrams 40 THANK YOU

Related presentations