Cse 470
Cse 470
Concrete
The name of the class is the only required
Class from application domain ClassName
tag in the graphical representation of a
Example: Customer class and Employee class. It always appears in the top-most
attributes compartment.
class
Abstract operations
Useful abstractions
Example: Person class
Classes
Attributes in a Class
A class is a description of a set of
Properties of the class about which we want to
ClassName objects that share the same attributes, capture information
operations, relationships, and semantics.
Represents a piece of information that is relevant to
attributes the description of the class within the application
Graphically, a class is rendered as a domain
rectangle, usually including its name,
operations Only add attributes that are primitive or atomic types
attributes, and operations in separate,
designated compartments. Derived attribute
attributes that are calculated or derived from other
attributes
denoted by placing slash (/) before name
Class Attributes
Operations in a Class
PhoneBook
Class Name
newEntry (n : Name, a : Address, p : PhoneNumber, d : Description)
getPhone ( n : Name, a : Address) : PhoneNumber
Attributes of Class
You can specify an operation by stating its signature: listing the name, type, and default
value of all parameters, and, in the case of functions, a return type.
Operations/methods
of Class
Depicting Classes
Visibility
When drawing a class, you need not show attributes and operation in every diagram.
of Attributes and Operations
Visibility (Cont’d)
Association Relationship
A bidirectional semantic connection
Person between classes
Attributes can be: Type:
+ name : String + public
# address : Address
# protected name of relationship
# birthdate : Date
/ age : Date - private role that classes play in the relationship
- ssn : Id / derived
+ eat ()
+ sleep ()
association
Menu
7/9/2021
TeachingAssistant
Generalization Relationships
Generalization Relationship
Person Person
A generalization connects a subclass
to its superclass. It denotes an
inheritance of attributes and behavior
from the superclass to the subclass and Employee Customer
indicates a specialization in the subclass
of the more general superclass.
Student
Manager Engineer
Employee Denotes
the minimum number..
hireDate
maximum number of instances
Exactly one 1
receivePay Zero or more 0..* or 0..m
performWork
One or more 1..* or 1..m
Zero or one 0..1
Manager Engineer Specified range 2..4
department certifications Multiple, disjoint ranges 1..3, 5
bonus
hireEmployee analyze
promoteEmployee design
Guidelines
for Analyzing Requirements / Use Cases (2) Class Diagram
An adjective implies an attribute of an Ensure that the classes are both necessary
object and sufficient to solve the underlying
A doing verb implies an operation
problem
no missing attributes or methods in each class
A being verb implies a relationship
no extra or unused attributes or methods in
between an object and its class each class
A having verb implies an aggregation or no missing or extra classes
association relationship
Checkout Screen
DVD Movie VHS Movie Video Game
44
7/9/2021
45
Slide 46