Download - Basic Class Diagrams
![Page 1: Basic Class Diagrams](https://reader035.vdocuments.site/reader035/viewer/2022062500/56814fcc550346895dbd8e00/html5/thumbnails/1.jpg)
GeneralizableElement
NamespaceModelElement
namevisibilityisSpecification
Classifier
isRoot
Constraint
Body
Coming up: Class Syntax
Basic Class Diagrams
CS/SWE 421
Introduction to Software Engineering
Dan Fleck(Slides adapted from Dr. Stephen Clyde with permission)
![Page 2: Basic Class Diagrams](https://reader035.vdocuments.site/reader035/viewer/2022062500/56814fcc550346895dbd8e00/html5/thumbnails/2.jpg)
Tool Issue (Jan 28, 2010) Netbeans 6.8 is out and the old UML plugin is no longer
maintained or working in 6.8 Another option: Visual Paradigm Community Edition (
http://www.visual-paradigm.com/download/sdenb.jsp?edition=ce ) Install Netbeans 6.8 Install SDE 5.2 Community Edition Register for Community (free) license Start Netbeans Create a project (any type) Tools-> Start SDE CE-NB
![Page 3: Basic Class Diagrams](https://reader035.vdocuments.site/reader035/viewer/2022062500/56814fcc550346895dbd8e00/html5/thumbnails/3.jpg)
Coming up: Class Names
Class Syntax A box divided into
compartments– Name– Attributes– Operations– Responsibilities (rarely
seen)– Used-defined
compartments (rarely seen)
Student
major: Stringgpa: Realstanding: String
add(Class Section)drop(Class Section)
-- The set of students known to the registration system
-- An exception occurs if gpa falls below 2.0
![Page 4: Basic Class Diagrams](https://reader035.vdocuments.site/reader035/viewer/2022062500/56814fcc550346895dbd8e00/html5/thumbnails/4.jpg)
Coming up: Exercise – Class Identification
Class Names The name should be a noun or noun
phrase The name should be singular and
description of each object in the class The name should be meaningful from a
problem-domain perspective– “Student” is better than “Student Data” or
“S-record” or any other implementation driven name
![Page 5: Basic Class Diagrams](https://reader035.vdocuments.site/reader035/viewer/2022062500/56814fcc550346895dbd8e00/html5/thumbnails/5.jpg)
Coming up: Attributes
Exercise – Class Identification
Identify meaningful classes in the Elevator System
![Page 6: Basic Class Diagrams](https://reader035.vdocuments.site/reader035/viewer/2022062500/56814fcc550346895dbd8e00/html5/thumbnails/6.jpg)
Coming up: Attributes from an Analysis Perspective
Attributes Attributes represent characteristics or
properties of classes They are place holders or slots that hold
values The values they hold are other objects (or
primitive types)
![Page 7: Basic Class Diagrams](https://reader035.vdocuments.site/reader035/viewer/2022062500/56814fcc550346895dbd8e00/html5/thumbnails/7.jpg)
Coming up: Attribute Syntax
Attributes from an Analysis Perspective An attribute relates an object to some other
object It has the same semantics as an association
joe: Student
name: String = “Joe Jones”
joe: Student Joe Jones : String
Is basically the same as ...
name
1
![Page 8: Basic Class Diagrams](https://reader035.vdocuments.site/reader035/viewer/2022062500/56814fcc550346895dbd8e00/html5/thumbnails/8.jpg)
Coming up: Operations
Attribute Syntax
visibility: public “+”, protected “#”, or private “-”
name: capitalize first letter of each word that makes up the name, except for the first
multiplicity: number, range, or sequence of number or ranges.
type: build-in type or any user-defined class
initial-value: any constant and user-defined object
property-string: e.g, changeable, addOnly, frozen
[visibility] name [multiplicity] [:type] [=initial-value][{property-string}]
![Page 9: Basic Class Diagrams](https://reader035.vdocuments.site/reader035/viewer/2022062500/56814fcc550346895dbd8e00/html5/thumbnails/9.jpg)
Coming up: Operation Syntax
Operations
Student
major: String
GPA: Real
standing: String
add(Class Section)
drop(Class Section)
Class Section
name: String
capacity: Integer
add(Student)
drop(Student)
checkPrerequisites(Students)
Prerequisite<
has
takes>
Course
![Page 10: Basic Class Diagrams](https://reader035.vdocuments.site/reader035/viewer/2022062500/56814fcc550346895dbd8e00/html5/thumbnails/10.jpg)
Coming up: Type of Relationships in Class Diagrams
Operation Syntax
visibility: “+”, “#”, “-”
name: verb or verb phase, capitalize first letter of every word, except first
parameter-list: coma separated list of parameters
return-type: primitive type or user-defined type
property-string: isQuery, sequential, guarded, concurrent
[visibility] name [(parameter-list)] [:return-type] [{property-strong}]
![Page 11: Basic Class Diagrams](https://reader035.vdocuments.site/reader035/viewer/2022062500/56814fcc550346895dbd8e00/html5/thumbnails/11.jpg)
Coming up: Associations
Type of Relationships in Class Diagrams
Relation
A consolidated snippet of the UML Meta-model
AssociationGeneralization Dependency
Aggregation
Binary Association N-ary Association
![Page 12: Basic Class Diagrams](https://reader035.vdocuments.site/reader035/viewer/2022062500/56814fcc550346895dbd8e00/html5/thumbnails/12.jpg)
Coming up: Associations
Associations An association is a structural relationship
that specifies that objects of class may be connected to objects of another class
Associations typically represent “long-lived” relationships (– e.g. In a library system a Person always has
a name (association), but may infrequently have a book (dependency)
![Page 13: Basic Class Diagrams](https://reader035.vdocuments.site/reader035/viewer/2022062500/56814fcc550346895dbd8e00/html5/thumbnails/13.jpg)
Coming up: Association Names
Associations
Student
Class Section
Course
Semester
Instructor
Department
takes>
is registered for>
teaches>
sponsors>
<w
orks
for is instance of>
is he
ld d
urin
g>
![Page 14: Basic Class Diagrams](https://reader035.vdocuments.site/reader035/viewer/2022062500/56814fcc550346895dbd8e00/html5/thumbnails/14.jpg)
Coming up: Navigation
Association Names
Associations may be named– The names should communicate the
meaning of the links– The names are typically verb phases– The name should include an arrow
indicating the direction in which the name should be read
– The direction on the name does NOT change navigability!
![Page 15: Basic Class Diagrams](https://reader035.vdocuments.site/reader035/viewer/2022062500/56814fcc550346895dbd8e00/html5/thumbnails/15.jpg)
Coming up: Navigation
Navigation The navigation of associations can be
– uni-directional– bi-directional– unspecified
Navigation is specified by the arrow, not the label
Class Section
Course
Instructor
Department
teaches>
sponsors>
<w
orks
for is instance of>
![Page 16: Basic Class Diagrams](https://reader035.vdocuments.site/reader035/viewer/2022062500/56814fcc550346895dbd8e00/html5/thumbnails/16.jpg)
Coming up: Generalization
Navigation
The navigation of association without an arrowhead is assumed to be undefined
Navigation has less value when modeling from a conceptual perspective– Why?
Navigation is more important during specification and implementation perspectives– Why?
![Page 17: Basic Class Diagrams](https://reader035.vdocuments.site/reader035/viewer/2022062500/56814fcc550346895dbd8e00/html5/thumbnails/17.jpg)
Coming up: Exercise – Simple Associations
Generalization Generalization is another kind of
relationship in UML In a Java implementation what is this?
StudentPerson Graduate Student
![Page 18: Basic Class Diagrams](https://reader035.vdocuments.site/reader035/viewer/2022062500/56814fcc550346895dbd8e00/html5/thumbnails/18.jpg)
Coming up: Class Diagrams
Exercise – Simple Associations
From an analysis perspective:– Identify meaningful associations and
generalization/specializations among classes in the Elevator System
![Page 19: Basic Class Diagrams](https://reader035.vdocuments.site/reader035/viewer/2022062500/56814fcc550346895dbd8e00/html5/thumbnails/19.jpg)
Coming up: Multiplicity Constraints
Class Diagrams
Class Diagrams describe– the types of objects in a system– their properties (attributes and operations)– relationships between objects
They can also include– Grouping concepts like packages– Constraints– Various kinds of annotations
![Page 20: Basic Class Diagrams](https://reader035.vdocuments.site/reader035/viewer/2022062500/56814fcc550346895dbd8e00/html5/thumbnails/20.jpg)
Coming up: Questions
Multiplicity Constraints
Student
Class Section
Course
Semester
Instructor
Department
takes>
is registered for>
teaches>
sponsors>
<w
orks
for is instance of>
is he
ld d
urin
g>
1..*1
1..*
1..*11
1..*
0..8
0..*
0..61..3
![Page 21: Basic Class Diagrams](https://reader035.vdocuments.site/reader035/viewer/2022062500/56814fcc550346895dbd8e00/html5/thumbnails/21.jpg)
Questions
From the previous diagram– How many classes can a student take?– Do you have to be registered in any classes
to be a student?– Do I need to teach this class to be an
Instructor? Do I need to teach ANY classes?
– Can a class have no students? Is that valid?
Coming up: Multiplicity Constraints
![Page 22: Basic Class Diagrams](https://reader035.vdocuments.site/reader035/viewer/2022062500/56814fcc550346895dbd8e00/html5/thumbnails/22.jpg)
Coming up: Dependencies
Multiplicity Constraints
A multiplicity constraint can be– a single number– a “*”, meaning an arbitrarily large number or
simply “many”– a range, denoted by “min..max”– a sequence of single numbers and ranges
1..2,7,10-20
This is also called the cardinality constraintThis is also called the cardinality constraint
![Page 23: Basic Class Diagrams](https://reader035.vdocuments.site/reader035/viewer/2022062500/56814fcc550346895dbd8e00/html5/thumbnails/23.jpg)
Coming up: Dependency Relationship
Dependencies
Relation
A consolidated snippet of the UML Meta-model
AssociationGeneralization Dependency
Aggregation
Binary Association N-ary Association
![Page 24: Basic Class Diagrams](https://reader035.vdocuments.site/reader035/viewer/2022062500/56814fcc550346895dbd8e00/html5/thumbnails/24.jpg)
Coming up: Dependencies
Dependency Relationship It says that
one modeling component “uses” another.
If the later changes then, the former may have to change as well
![Page 25: Basic Class Diagrams](https://reader035.vdocuments.site/reader035/viewer/2022062500/56814fcc550346895dbd8e00/html5/thumbnails/25.jpg)
Coming up: Aggregations (is part of)
Dependencies
Syntax:– a dashed link with an straight-line
arrowhead point to a component on which there is a dependency
Dependencies can be defined among: classes, notes, packages, and other types of components
Can dependencies go both ways? Any problems with having lots of
dependencies?
![Page 26: Basic Class Diagrams](https://reader035.vdocuments.site/reader035/viewer/2022062500/56814fcc550346895dbd8e00/html5/thumbnails/26.jpg)
Coming up: Aggregation
Aggregations (is part of)
Relation
A consolidated snippet of the UML Meta-model
AssociationGeneralization Dependency
Aggregation
Binary Association N-ary Association
![Page 27: Basic Class Diagrams](https://reader035.vdocuments.site/reader035/viewer/2022062500/56814fcc550346895dbd8e00/html5/thumbnails/27.jpg)
Coming up: Composition (very similar to aggregation)
Aggregation Aggregation: is a special kind of association
that means “part of” Aggregations should focus on single type of
composition (physical, organization, etc.)
1 1
*
4..*
1
1
1 1
1..3 1
0..9 1
Pizza Order
Slice
Crust
Sauce Serving
Cheese Serving
Topping Serving
![Page 28: Basic Class Diagrams](https://reader035.vdocuments.site/reader035/viewer/2022062500/56814fcc550346895dbd8e00/html5/thumbnails/28.jpg)
Coming up: Lets look at BookstoreExample4.jpg
Composition (very similar to aggregation)
Think of composition as a stronger form of aggregation. Composition means something is a part of the whole, but cannot survive on it’s own.
BuildingRoom
![Page 29: Basic Class Diagrams](https://reader035.vdocuments.site/reader035/viewer/2022062500/56814fcc550346895dbd8e00/html5/thumbnails/29.jpg)
Lets look at BookstoreExample4.jpg Does John McCain (who has 7 houses) have
a problem using this system? If Barack Obama decides to create a Federal
sales tax, how would we change the system?
Why is there a display method in Item, Book, MusicCD and Software?
An ItemOrder is part of how many Orders? Can you explain how a search works using
this diagram?Coming up: Class Exercise
![Page 30: Basic Class Diagrams](https://reader035.vdocuments.site/reader035/viewer/2022062500/56814fcc550346895dbd8e00/html5/thumbnails/30.jpg)
Class Exercise
Lets create the WeGrow class diagram
Coming up: Safety System Example
![Page 31: Basic Class Diagrams](https://reader035.vdocuments.site/reader035/viewer/2022062500/56814fcc550346895dbd8e00/html5/thumbnails/31.jpg)
Safety System Example A safety software system for housing areas:
– enables its owner to configure it during installation, – controls through its sensors the environmental areas against fire and burglary and – interacts with the owner through the keypad of the system control panel.
During installation, the system programming and configuration is carried out by using the numerical and functional keys of the control panel. Each sensor in the system is identified by a number and a type (fire or burglary). The system stores two passwords (each of them is up to six digits) used for the system activation/deactivation and a telephone number used for emergency calls when an alarm event arises. The system polls the fire sensors for M seconds, then disables them for other N seconds. After that, the system resumes the same cycle. The Ready indicator is lighting when the sensors are polled and is turned o when ffthe sensors are disabled. When a sensor indicates an event, the system launches an alarm signal. After K seconds, the system calls the security forces office and provides it with information about the event nature and location. In order to log in, the owner enters the password and presses Enter. If any of the six digits is wrong the password is ignored by the system and the sensors’s state doesn’t change. The owner can cancel the password with the Clear key. If a sensor is activated, the system is armed and the Armed indicator on the control panel is turn on. In the case of the sensor deactivation, the Armed indicator is turn o . Moreover, the ffsystem logs all events. Each logged event is characterized by its type and the date and time of its occurrence. The event list can be delivered by pressing the MEM key.
Coming up: Questions
Example specification from: http://www.emis.de/journals/ASUO/mathematics/pdf3/bogdan.ps
![Page 32: Basic Class Diagrams](https://reader035.vdocuments.site/reader035/viewer/2022062500/56814fcc550346895dbd8e00/html5/thumbnails/32.jpg)
Coming up: More Questions
Questions What’s the difference between an attribute and an
association with another class? For example, should “grade” be an attribute or a link to another class called “Grade”?
When during the software engineering life cycle should you build classes diagrams?
![Page 33: Basic Class Diagrams](https://reader035.vdocuments.site/reader035/viewer/2022062500/56814fcc550346895dbd8e00/html5/thumbnails/33.jpg)
Coming up: What’s important
More Questions
How do you know when a class diagram is complete?
How can you manage change control on all the class diagrams for project?
What do you do with class diagrams after a system has been built and delivered?
![Page 34: Basic Class Diagrams](https://reader035.vdocuments.site/reader035/viewer/2022062500/56814fcc550346895dbd8e00/html5/thumbnails/34.jpg)
What’s important
Understading the 3 main parts of the class box
Generalization/Specialization Associations and multiplicity constraints Aggregation (and composition) understand
how to use them, but don’t worry about the differences between them – too subtle
Coming up: Bonus Slide!
![Page 35: Basic Class Diagrams](https://reader035.vdocuments.site/reader035/viewer/2022062500/56814fcc550346895dbd8e00/html5/thumbnails/35.jpg)
Bonus Slide!
If you’re interested in Auto-generating UML, Netbeans has an option to do it.– Install the UML plugin– Right-click on a project– Choose “Reverse Engineer”– Go to the new UML project– Select a package and choose to generate a
new UML diagram This may not be true anymore with the new
plugin!
End of presentation