Information Systems Analysis and Design CSC340© 2004 John Mylopoulos Class Diagrams -- 1III. Class and Object DiagramsIII. Class and Object DiagramsClasses, Attributes and OperationsObjects and Multi-objectsGeneralization and InheritanceAssociations and MultiplicityAggregation and CompositionBusiness Objects and Rules©2004 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”). Finding classes: Listen to the domain experts (…thepeople who know the domain you are modeling!)©2004 John MylopoulosCSC340Information Systems Analysis and DesignClass Diagrams -- 3Diagrammatic Notation for ClassesDiagrammatic Notation for ClassesStaffMemberstaffNameCalculateBonus()ChangeGrade()Name (mandatory)Attributes (optional)Operations (optional)Modelingthe “realworld”©2004 John MylopoulosCSC340Information Systems Analysis and DesignClass Diagrams -- 4System ClassesSystem ClassesStaffMemberstaffNameCalculateBonus()ChangeGrade()This is a Javaclass to beincluded in thedesign of thenew system©2004 John MylopoulosCSC340Information Systems Analysis and DesignClass Diagrams -- 5AttributesAttributes Each class can have attributesattributes which representuseful information about instances of a class. Each attribute has a typetype. For example, Campaign has attributes title anddatePaid.Campaigntitle: StringdatePaid: Date©2004 John MylopoulosCSC340Information Systems Analysis and DesignClass Diagrams -- 6Objects are Class InstancesObjects are Class InstancesSaveTheKids:Campaigntitle: “Save the kids”datePaid: 28/01/02©2004 John MylopoulosCSC340Information Systems Analysis and DesignClass Diagrams -- 7Object DiagramsObject DiagramscourseNo: csc340"description: “OOAD":Course:StudentBillClinton:Monica:Studentsomeone:Jaelson:Instructor©2004 John MylopoulosCSC340Information Systems Analysis and DesignClass Diagrams -- 8MultiobjectsMultiobjectsA multiobject is a set of objects, with an undefinednumber of elementsp2:Instructorc1:Coursec2:Coursec3:Course:Student:StudentMultiobjects©2004 John MylopoulosCSC340Information Systems Analysis and DesignClass Diagrams -- 9OperationsOperations Often derived from action verbs in the description of theapplication. Operations describe what can be done with theinstances of a class.©2004 John MylopoulosCSC340Information Systems Analysis and DesignClass Diagrams -- 10CampaignTitle:StringCampaignStartDate:DateCampaignFinishDate:DateEstimatedCost:MoneyActualCost:MoneyCompletionDate:DateDatePaid:DateCompleted(CompletionDate:Date,ActualCost:Money)SetFinishDate(FinishDate:Date)RecordPayment(DatePaid:Date)CostDifference():MoneyOperationsOperations©2004 John MylopoulosCSC340Information Systems Analysis and DesignClass Diagrams -- 11VisibilityVisibility As with Java, attributes and operations can bedeclared with different visibility modes:+ publicpublic: any class can use the feature (attribute oroperation);# protectedprotected: any descendant of the class can usethe feature;--privateprivate: only the class itself- can use the feature.Staffname : Stringpasswd : StringdateofB : DateChangePasswd()Include()publicprivateprotected©2004 John MylopoulosCSC340Information Systems Analysis and DesignClass Diagrams -- 12RelationshipsRelationships Classes and objects do not exist in isolation fromone another A relationship represents a connection amongthings. In UML, there are different types of relationships: Generalization Association Aggregation Composition …more…©2004 John MylopoulosCSC340Information Systems Analysis and DesignClass Diagrams -- 13GeneralizationGeneralization CreativeStaffqualificationsHire()CalculateBonus() StaffMemberstaff#:Integername:StringstartDate:DategradeHire()ChangeGrade()CalculateBonus() AdminStaffHire()CalculateBonus()Superclass or parentSubclasses or children©2004 John MylopoulosCSC340Information Systems Analysis and DesignClass Diagrams -- 14 Inheritance of attributes Inheritance of operations Overriding inherited attributes or operations.InheritanceInheritance©2004 John MylopoulosCSC340Information Systems Analysis and DesignClass Diagrams -- 15AdvertHoarding Advert Press Advert Video AdvertNewspaper Advert Magazine Advert**BillboardFindingFinding Inheritance Inheritance©2004 John MylopoulosCSC340Information Systems Analysis and DesignClass Diagrams -- 16Finding Inheritance, Finding Inheritance, …… Bottom Up Bottom Up BooktitleauthorpublisherISBNDeweyCodeacquisition#Loan()Return() RecordCDtitlecatalogue#publisherartistacquisition#Loan()Return()©2004 John MylopoulosCSC340Information Systems Analysis and DesignClass Diagrams -- 17...Better!...Better! LoanItemtitleacquisition#Loan()Return() BookAuthorDeweyCodepublisherISBN Recordartistcatalogue#recordCoAll classes in thisdiagram model realworld entities©2004 John MylopoulosCSC340Information Systems Analysis and DesignClass Diagrams -- 18Generalization NotationGeneralization NotationPossibly overlapping Mutually exclusiveMaria is both Lecturer a lecturer can’t be aand Student student and vice versaPersonPersonStudentLecturerStudent Lecturer©2004 John MylopoulosCSC340Information Systems Analysis and DesignClass Diagrams -- 19ClassificationClassification This is the relationship between an object and theclasses of which it is an instance. Traditional object models assume that classification issinglesingle and staticstatic.Multiple classification allows an object to be an instanceof several classes that are not is-a related to each other;for example, Maria may be an instance ofGradStudent and Employee.DynamicDynamic classification allows an object to change itstype during its lifetime.©2004 John MylopoulosCSC340Information Systems Analysis and DesignClass Diagrams -- 20Multiple ClassificationMultiple ClassificationPersonTAProfessorStaffMaleFemaleStudentstudentsex<<mandatory>>role<<dynamic>>©2004 John MylopoulosCSC340Information Systems Analysis and DesignClass Diagrams -- 21Association RelationshipsAssociation Relationships StaffMemdernamestaff#startDatequalification CampaigntitlestartDateestimatedCostmanagesmanagernamerole©2004 John MylopoulosCSC340Information Systems Analysis and DesignClass Diagrams -- 22 How many
View Full Document