Class Diagram Mehwish Shafiq
Class Collection of object that share common properties, attributes, and behavior. Collection of objects with same data structures (attributes) and behavior (Function, code, operation).
Classification & Instantiation Grouping common objects in a class is classification. Instantiation is the Act of creating an instance.
Example
Representing a class Class Name Attributes Methods
Members of a Class Attributes and Methods Their Visibility has 3 types Public “+” Private “-” Protected “#”
Example-Visibility Student - enrolment_no : String - award : String + set_number(number ): int + set_award(award) + get_number() + get_award()
Interface We access objects by calling its methods. Set of method calls available for object are called its interface. Student - enrolment_no : String - award : String + set_number(String n ) + set_award(String a ) + get_number( ) + get_award( )
More about Classes Define classes that collaborate to perform required task. Define classes that deliver required use cases. Defining classes=defining overall system architecture.
Identifying Classes identify the important things mentioned in the text usually described as ‘things of interest in the system’ ‘things of interest’ = things = nouns normally nouns and noun phrases Noun identification process: underline all nouns and noun phrases gives a first rough list refine/analyse/eliminate rough list to produce candidate class list
Refining First Noun List convert plurals to singular Books > Book remove synonyms choose one of ‘library-member’ & ‘member of the library’ remove anything vague/ambiguous, or clarify it usually remove events or actions remove anything outside the scope of the system gives list of possible classes
Refining Candidate Class List check relevance/role/need for the class would Publisher be a class, or just an attribute of Book
Dealing with Uncertainty? if in doubt keep it in the list? or not? keeping it in may cause confusion/ambiguity leaving it out may lose information some analysts keep 2 lists definites and maybes
What kind of things might be classes? real-world tangible things - Book, Copy real-world intangibles - Course, Unit roles - Borrower, Student sometimes (but often not)-> events, interactions loan, appointment
Actors and classes is an actor a class in the system? Yes, if system needs to store information about the actor, for example BookBorrower becomes Library_member