CSC 335: ObjectOriented Programming and Design - PowerPoint PPT Presentation

1 / 25
About This Presentation
Title:

CSC 335: ObjectOriented Programming and Design

Description:

one view has pictures such as UML diagrams. the source code is another view. 4-4 ... Car. Wheel. 4. Car. Wheel. 5. Car. Wheel. 3. 1. 1. 1. 4-18. Association ... – PowerPoint PPT presentation

Number of Views:21
Avg rating:3.0/5.0
Slides: 26
Provided by: rickm1
Category:

less

Transcript and Presenter's Notes

Title: CSC 335: ObjectOriented Programming and Design


1
CSC 335 Object-Oriented Programming and Design
Presentation 4 Introduction to Unified Modeling
Language (UML)
2
The Unified Modeling Language (UML)
  • UML or Unified Modeling Language comes from
    Rumbaugh, Booch, and Jacobson (the three amigos)
    who have combined efforts to standardize on one
    modeling language
  • This is primarily a graphical communication
    mechanism for developers and customers
  • We will learn some, but not all, of the UML
  • it is very complex, few understand all of it

3
UML
  • The main purpose of UML is to
  • support communication about the analysis and
    design of the system being developed
  • support the movement from the problem domain in
    the "world" to the solution domain in the machine
  • two views of the same system
  • one view has pictures such as UML diagrams
  • the source code is another view

4
UML is a Modeling Language
  • UML
  • is a graphical notation that describes software
    design
  • has rules on how to draw models of
  • classes
  • associations between objects
  • associations between classes and interfaces
  • message sends between objects
  • has become the industry standard
  • is like a blueprint for what is going on during
    analysis, design and implementation

5
UML Defined by the Authors
  • From The Unified Modeling Language User Guide,
    Booch, Rumbaugh, Jacobson
  • The UML is a language for
  • visualizing
  • specifying
  • constructing
  • documenting
  • the artifacts of a software intensive system

6
First up Design Class Diagrams
  • A class diagram
  • expresses class definitions to be implemented
  • lists name, attributes, and methods for each
    class
  • shows how instances will connect to one others
  • UML allows different levels of detail on both the
    attributes and the methods of one class
  • could be just the the class name in a rectangle
  • or like the general form shown on the next slide

7
Software Specification Class Name
attribute

attribute type
attribute type initial value
classAttribute
derivedAttribute
...
method1()
method2(parameter Type) return type
abstractMethod()
publicMethod()
-privateMethod()
protectedMethod()
classMethod()
...
8
AccountCollection

- allAccounts HashMap
AccountCollection ()
getAccountWithID (ID String) Account
add(accountToAdd Account) boolean
iterator() Iterator
Note iterator is needed by the bank manager
9
Sterotypes
  • Stereotype is a UML element that allows us to
    extends the UML vocabulary
  • Often used to distinguish an abstract class name
    from an interface, both of which are written in
    italic

ltltinterfacegtgt Iterator hasNext()
boolean next() Object remove() void
10
Different levels of detail
  • Tips for modeling
  • Express as much or as little detail as needed
  • Often, a rectangle with a name is enough
  • perhaps a method or an attribute adds to the
    clarity
  • Simple is good
  • Sketches on paper or white board are effective

11
Relationships
  • Three Relationships in UML
  • 1) Dependency
  • 2) Association
  • 3) Generalization
  • Understanding these relationships is more
    important than the lines that UML uses

12
1) Dependency A Uses Relationship
  • Dependencies
  • occurs when one object depends on another
  • if you change one object's interface, you need to
    change the dependent object
  • arrow points from dependent to needed objects

CardReader
Jukebox
CDCollection
SongSelector
13
2)Association Structural Relationship
  • Association
  • a relationship between classes indicates some
    meaningful and interesting connection
  • Name the association with a hyphen connected verb
    phrase which reads well between concepts

association
getAccountWithID
JukeboxAccountCollection
Jukebox
1
1
14
Associations
  • Associations imply
  • our knowledge that a relationship must be
    preserved for some time (1 ms to forever)
  • between what objects do we need to remember a
    relationship?
  • Does a Transaction need to remember the Account?
  • maybe yours did, maybe you changed it
  • Does AccountCollection need to remember Accounts?

Stores
AccountCollection
Account
1

15
Notation and Multiplicity Adornments
  • UML Association
  • a line between two concepts and a name
  • they are bi-directional
  • can have a multiplicity
  • exist in conceptual
  • models and
  • class diagrams

zero or more

T
"many"

1..
one or more
T
1..40
one to forty
T
5
Multiplicity adornments
exactly five
T
3, 5, 8
exactly three,
T
five or eight
16
Multiplicity
  • Multiplicity defines how many instances of type A
    can be associated with one instance of type B at
    some point can differ

Game
Player
1
2..6
Mother
Child
1
1
Actor is associated with 0 to many films. A film
is associated with 0 to many actors
performs-in
Actor
Film


can optionally name an association
17
Depends on Context
  • Are all three associations possible?

Car
Wheel
4
1
Car
Wheel
5
1
Car
Wheel
1
3
18
Association Names Upcase / hyphenate
  • Read this Type-VerbPhrase-Type (POST is a Point
    of Sale Terminal)
  • Not yet worrying about messages, instance
    variables, data flow, or classes
  • Just shows objects are connected somehow

19
Aggregation A Special Association
  • Aggregation whole/part relationships
  • An association that models HAS-A relationships
  • The objects can exist independently or each other
  • No one object is more important than the other
  • Place an open diamond on the whole
  • Could mean School has a HashMap of Students

School
Student
1..

20
Composition A Special Association
  • Composition Stronger relationship
  • One can not exist without the other
  • If the school folds, students live on
  • but the departments go away also
  • If a department closes, the school can go on AIC
    e.g.
  • Model aggregation or composition? When in doubt,
    use association (just a simple line)

School
Department
1
1..
1..

Student
21
Sequence Diagrams
  • A class diagram shows a fixed view of the system
  • A sequence diagram represents a dynamic view of a
    system by attempting to capture messages sends
    over time
  • Can document a scenario such as
  • User Selects Song

22
Sequence Diagrams
  • Objects are lined up on top in rectangles
  • Object names theJukebox
  • Dashed lines are the lifetime of the object
  • Rectangles are activation lines
  • When the object has control
  • Activation bar of the receivers of the message is
    smaller than the sender's activation bar
  • No branches, no loops, not much detail

23
http//www.ifi.uio.no/in219/verktoy/doc/html/doc/u
ser/mg/dgmsuml6.html
24
http//www.visual-paradigm.com/ VPGallery/diagrams
/Sequence.html
25
Let's try one for Jukebox
  • Draw a sequence diagram for the scenario User
    selects a song
Write a Comment
User Comments (0)
About PowerShow.com