Information Systems Analysis and Design CSC340© 2001 Jaelson Castro and John Mylopoulos Class Diagrams -- 1III. Class and Object DiagramsIII. Class and Object DiagramsClasses, Attributes and OperationsObjects and Multi-objectsGeneralization and InheritanceAssociations and MultiplicityAggregation and CompositionHow to Use Class Diagrams©2003 John MylopoulosCSC340Information Systems Analysis and DesignClass Diagrams -- 2ClassesClasses A class describes a group of objects with similar properties (attributes), common behaviour (operations), common relationships to other objects, and common meaning (“semantics”). For example, “employee: has a name, employee# anddepartment; an employee is hired, and fired; an employeeworks in one or more projects”©2003 John MylopoulosCSC340Information Systems Analysis and DesignClass Diagrams -- 3Finding ClassesFinding Classes Finding classes in use case, or in text descriptions: Look for nouns and noun phrases in the description of a usecase or a problem statement; These are only included in the model if they explain the natureor structure of information in the application. Don’t create classes for concepts which: Are beyond the scope of the system; Refer to the system as a whole; Duplicate other classes; Are too vague or too specific (few instances); Finding classes in other sources: Reviewing background information; Users and other stakeholders; Analysis patterns; CRC (Class Responsibility Collaboration) cards.©2003 John MylopoulosCSC340Information Systems Analysis and DesignClass Diagrams -- 4StaffMemberStaffMember Class for Agate Class for Agate For example, we may want to represent the concept of a staffmember for a company such as Agate in terms of the classStaffMember.StaffMemberstaffNameCalculateBonus()ChangeGrade()Name (mandatory)Attributes (optional)Operations (optional)©2003 John MylopoulosCSC340Information Systems Analysis and DesignClass Diagrams -- 5NamesNames Every class must have a unique name Each class has instances that represent particular individualsthat have the properties of the class. For example, George, Nazim, Yijun,… may be instances ofStaffMember. Classes can be used to describe a part of the real world, orpart of the system under design.Client Campaign StaffMember©2003 John MylopoulosCSC340Information Systems Analysis and DesignClass Diagrams -- 6AttributesAttributes Each class can have attributesattributes which represent usefulinformation about instances of a class. Each attribute has a typetype. For example, Campaign has attributes title and datePaid.Campaigntitle: StringdatePaid: Date©2003 John MylopoulosCSC340Information Systems Analysis and DesignClass Diagrams -- 7Objects and Their Attribute ValuesObjects and Their Attribute Values The instances of a class are called objects. Objects are represented as shown below. Two different objects may have identical attribute values (liketwo people with identical name and address) Make sure that attributes are associated with the right class; forexample, you don’t want to have both managerName,managerEmp# as attributes of Campaign! (...Why??)SaveTheKids:Campaigntitle: “Save the kids”datePaid: 28/01/02©2003 John MylopoulosCSC340Information Systems Analysis and DesignClass Diagrams -- 8Object DiagramsObject Diagrams Model the instances of things described by a class. Each object diagram shows a set of objects and their inter-relationships at a point in time. Used to model a snapshot of the application. Each object has an optional name and set of classes it is aninstance of, also values for attributes of these classes.courseNo: csc340"description: “OOAD":Course:StudentBillClintonMonica:Studentsomeone:Jaelson:Instructor©2003 John MylopoulosCSC340Information Systems Analysis and DesignClass Diagrams -- 9MultiobjectsMultiobjectsA multiobject is a set of objects, with an undefined number ofelementsp2:Instructorc1:Coursec2:Coursec3:Course:Student:StudentMultiobjects©2003 John MylopoulosCSC340Information Systems Analysis and DesignClass Diagrams -- 10OperationsOperations Often derived from action verbs in use case descriptions orproblem statements. Operations describe what can be done with the instances of aclass. For example, For the class Stone, we may want to associateoperations Throw(), Kick() and WriteOn(). Some operations will carry out processes to change or docalculations with the attributes of an object. For example, the directors of Agate might want to know thedifference between the estimated cost and the actual cost of acampaign Campaign would need an operation CostDifference()©2003 John MylopoulosCSC340Information Systems Analysis and DesignClass Diagrams -- 11 Each operationhas a signaturesignature,which specifiesthe types of itsparameters andthe type of thevalue it returns(if any).CampaignTitle:StringCampaignStartDate:DateCampaignFinishDate:DateEstimatedCost:MoneyActualCost:MoneyCompletionDate:DateDatePaid:DateCompleted(CompletionDate:Date,ActualCost:Money)SetFinishDate(FinishDate:Date)RecordPayment(DatePaid:Date)CostDifference():MoneyOperationsOperations©2003 John MylopoulosCSC340Information Systems Analysis and DesignClass Diagrams -- 12VisibilityVisibility As with Java, attributes and operations can be declared withdifferent visibility modes:+ publicpublic: any class can use the feature (attribute or operation);# protectedprotected: any descendant of the class can use the feature;- privateprivate: only the class itself can use the feature.Staffname : Stringpasswd : StringdateofB : DateChangePasswd()Include()publicprivateprotected©2003 John MylopoulosCSC340Information Systems Analysis and DesignClass Diagrams -- 13RelationshipsRelationships Classes and objects do not exist in isolation from one another A relationship represents a connection among things. In UML, there are different types of relationships: Generalization Association Aggregation Composition …more…©2003 John MylopoulosCSC340Information Systems Analysis and DesignClass Diagrams -- 14Generalization RelationshipGeneralization Relationship Generalization relates two classes when the conceptrepresented by one class is more general than thatrepresented by the other. For example, Person is a generalization of Student, andconversely, Student is a specialization of Person. The
View Full Document