Software PatternsSlide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Slide 10Slide 11Slide 12Slide 13Slide 14Slide 15Classes in UML (1)Slide 17Classes in UML (3)Classes in UML (4)Classes in UML (5)Objects in UML (1)Objects in UML (2)Slide 23Objects in UML (4)Objects in UML (5)Attributes in UML (1)Attributes in UML (2)Attributes in UML (3)Attributes in UML (4)Operations, Methods in UML (1)Operations, Methods in UML (2)Operations, Methods in UML (3)Operations, Methods in UML (4)Operations, Methods in UML (5)Constraints in UML (1)Constraints in UML (2)Constraints’ Examples in UML (3)Constraints’ Examples in UML (4)Constraints’ Examples in UML (5)Constraints’ Examples in UML (6)Constraints’ Examples in UML (7)Constraints’ Examples in UML (8)Constraints’ Examples in UML (9)Notes in UML (1)Notes in UML (2)2003SJSU -- CmpE L3-S1 Class DiagramsSoftware PatternsDr. M.E. Fayad, ProfessorComputer Engineering Department, Room #283I College of EngineeringSan José State UniversityOne Washington SquareSan José, CA 95192-0180 http://www.engr.sjsu.edu/~fayad2003SJSU – CmpE M.E. Fayad L3-S2 Class Diagrams2Lesson 03:Class Diagrams2003SJSU – CmpE M.E. Fayad L3-S3 Class Diagrams Lesson ObjectivesObjectives3 Explore Modeling Notation Understand Objects, Attributes, Operations, and Notes in UMLDiscuss the following:– Different Kind of Classes– Class Diagrams2003SJSU – CmpE M.E. Fayad L3-S4 Class DiagramsNotationNotation Again !Modeling Notation42003SJSU – CmpE M.E. Fayad L3-S5 Class DiagramsReal-world systems can be decomposed into discrete entities called objectsObjects represent things, concepts, or abstraction with definable boundaries and behaviorsAn object is specific instance of a class to which it belongsClasses have attributes and behaviorsIndividual objects have their own specific values for each attribute and share the same behaviorsObjects & Classes (1)52003SJSU – CmpE M.E. Fayad L3-S6 Class DiagramsExample Objects Classes AttributesA computer screen Screen Resolution, # of colorsA window Window Size, locationIBM Company Name, location, total revenue Joe Harris Employee Name, department, salaryObjects & Classes (2)62003SJSU – CmpE M.E. Fayad L3-S7 Class DiagramsObjects & Classes (3)Objects with the same attributes, behaviors, and relationships are grouped together into classesA class describes general attributes and behaviors for a group of objectsAn object is a single instance of its class (e.g., IBM is an instance of the Company class)A Class diagram is used to describe the attributes and behaviors of a class72003SJSU – CmpE M.E. Fayad L3-S8 Class DiagramsClasses (1)Classes are the most important building block of any Classes are the most important building block of any object-oriented systemobject-oriented systemA class is a description of a set of objects that share A class is a description of a set of objects that share the same attributes, operations, relationships, and the same attributes, operations, relationships, and semantics.semantics.Graphically, a class is rendered as a rectangleGraphically, a class is rendered as a rectangle82003SJSU – CmpE M.E. Fayad L3-S9 Class DiagramsClasses (2)9RegistrationFormRegistrationManagerCourseStudentCourseOfferingProfessorScheduleAlgorithm2003SJSU – CmpE M.E. Fayad L3-S10 Class DiagramsNaming & AttributesNaming & AttributesNamingNaming Classes should be named using the vocabulary of the domainClasses should be named using the vocabulary of the domainNaming standards should be created -- e.g., all classes are Naming standards should be created -- e.g., all classes are singular nouns starting with a capital lettersingular nouns starting with a capital letterAttributesAttributesAn attribute is a named property of a class that describes a An attribute is a named property of a class that describes a range of values that instances of the property may holdrange of values that instances of the property may hold102003SJSU – CmpE M.E. Fayad L3-S11 Class DiagramsAttributes11Each course offeringhas a number, location and timeCourseOfferingnumberlocationtime2003SJSU – CmpE M.E. Fayad L3-S12 Class DiagramsOperationsOperationsAn operation is the implementation of a service that An operation is the implementation of a service that can be requested from any object of the class to affect can be requested from any object of the class to affect behaviorbehavior12RegistrationManageraddCourse(Student,Course)2003SJSU – CmpE M.E. Fayad L3-S13 Class DiagramsFinding ClassesWhere to find candidate classes:Where to find candidate classes:o Nouns in descriptions or conversationNouns in descriptions or conversationo Checklists of general/typical object typesChecklists of general/typical object typeso Similar computerized systemsSimilar computerized systemso Technical literature in the problem domainTechnical literature in the problem domain132003SJSU – CmpE M.E. Fayad L3-S14 Class DiagramsExample Classes14Phenomena ClassesThing Car, goods, packaging, materialsPeople & roles Employee, parent, customer, memberOrganizations Company, department, group, projectPlaces Shelf, parking spot, construction site, cityConcepts Square, currency, quality parameters, feeResources Money, time, energy, labor force, infoApparatuses Radar, sensor, valve, motorSystems Street register, cash register, alarm system2003SJSU – CmpE M.E. Fayad L3-S15 Class DiagramsEvaluating ClassesDoes the class contain unique information?Does the class contain unique information?Does the class encompass multiple objects?Does the class encompass multiple objects?Can we identify objects from the class?Can we identify objects from the class?Does the class have a manageable number of Does the class have a manageable number of operations?operations?Does the class embodies a well-defined responsibility?Does the class embodies a well-defined responsibility?152003SJSU – CmpE M.E. Fayad L3-S16 Class Diagrams16Classes in UML (1)ClassAbstractClass<<utility>>UtilityClassattributeoperation()<<Stereotype>>Package::Class{Constraints}Syntax for attributes and operationsAttribute[Cardinality]:Package::Type = InitialValue {Constraints}Operation(ArgumentList):ReturnType {Constraints}<<metaclass>>MetaClass<<ActiveClass>>ActiveClass2003SJSU – CmpE M.E. Fayad L3-S17 Class Diagrams17Classes in UML
View Full Document