csc 213 – large scale programming. today’s goal learn unified process to design programs ...
TRANSCRIPT
![Page 1: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/1.jpg)
LECTURE 2:UML CLASS DIAGRAM
CSC 213 – Large Scale Programming
![Page 2: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/2.jpg)
Today’s Goal
Learn Unified Process to design programs Understand what are the “types” of Java
classes Methods of selecting the potential classes How these designs presented for others to
use
![Page 3: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/3.jpg)
Classroom Development
Always start from scratch Know all requirements from the start
And requirements will not change Coding begins immediately at start
Projects are trivial jokes in real-world If lasts 15 weeks, project “large scale”
Code cannot be reused Never look at again, anyway
![Page 4: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/4.jpg)
Why These Phases Matter
![Page 5: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/5.jpg)
Our Goal
![Page 6: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/6.jpg)
Our Nemesis
![Page 7: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/7.jpg)
Other Nemesis
![Page 8: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/8.jpg)
Other Nemesis
![Page 9: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/9.jpg)
Where We Start
![Page 10: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/10.jpg)
Find the Classes
Designing classes next step in process Could help find & fix inconsistent
requirements Requirements clarified if you do not
understand them Outlining classes makes coding easy
Already know methods to call from other classes
Will provide chance to do some easy debugging
![Page 11: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/11.jpg)
Noun Extraction
Finds entity class candidates to be used in design Initial pass may (will) not find all entity
classes Some classes not used even though found
early on Provides strong hints for other needed
classes Start with plain English requirements
Should be easy & comes with most assignments
Many nouns not needed, so can prune list Eliminate any & all classes external to
program
![Page 12: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/12.jpg)
Designing Elevator Controller
Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed.
![Page 13: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/13.jpg)
Noun Extraction
1. Underline the nouns in the requirements
Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed.
![Page 14: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/14.jpg)
1. Underline the nouns in the requirements
Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed.
Noun Extraction
![Page 15: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/15.jpg)
2. Eliminate nouns external to the problem
Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed.
Noun Extraction
![Page 16: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/16.jpg)
2. Eliminate nouns external to the problem
Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed.
Noun Extraction
![Page 17: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/17.jpg)
3 “Types” of Classes
Unified Process concept simplifies design process Entity classes hold long-lived data driving
program Input & output handled by boundary
classes Control classes do complex processing in
program "Types" not real, exist for design
purposes only A class is a class is a class within Java &
program But they can help checking design covers all
needs
![Page 18: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/18.jpg)
Entity Classes
![Page 19: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/19.jpg)
Entity Classes
Focus on entity classes & ignore (for now) others Since not things, prune abstract (non-
physical) nouns Ignore if used for communication – rarely
drive program Thinking will change -- must work
iteratively Writing & debugging easier given good design Minutes spent in design saves hours in coding
& testing
![Page 20: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/20.jpg)
“Must work iteratively” !=
![Page 21: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/21.jpg)
Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed.
Find Entity Classes
![Page 22: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/22.jpg)
1. Ignore abstract (non-physical) nouns
Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed.
Find Entity Classes
![Page 23: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/23.jpg)
1. Ignore abstract (non-physical) nouns
Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed.
Find Entity Classes
![Page 24: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/24.jpg)
2. Only use singular form of each noun
Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed.
Find Entity Classes
![Page 25: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/25.jpg)
2. Only use singular form of each noun
Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed.
Find Entity Classes
![Page 26: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/26.jpg)
Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed.
Button Floor Elevator
Our Entity Classes
![Page 27: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/27.jpg)
Boundary Classes
These classes will perform all input & output May have many details which are all
independent Only 1 detail known: it will change before
its over Make class for each detail & limit future
rewriting Make life easier, start from simplest
ideas Easy to combine simple classes to create
complex ones Taking a complex class and breaking up far
harder Rarely rewrite complex classes because of
difficulty…… instead often just throw out & start from scratch
![Page 28: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/28.jpg)
Skipping Boundary Classes
Boundary classes may duplicate primitive type Can eliminate this class; it adds nothing to
design Code will have primitive hard-coded
everywhere Saves writing javadoc for class, field, getter
& setter When needs change and class now
needed…
![Page 29: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/29.jpg)
Skipping Boundary Classes
Boundary classes may duplicate primitive type Can eliminate this class; it adds nothing to
design Code will have primitive hard-coded
everywhere Saves writing javadoc for class, field, getter
& setter When needs change and class now
needed… Find & replace all primitives littering code Scan entire program to track down all I/O
for this data Retest entire application to ensure now
bugs created
![Page 30: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/30.jpg)
Skipping Boundary Classes
Boundary classes may duplicate primitive type Can eliminate this class; it adds nothing to
design Code will have primitive hard-coded
everywhere Saves writing javadoc for class, field, getter
& setter When needs change and class now
needed… Find & replace all primitives littering code Scan entire program to track down all I/O
for this data Retest entire application to ensure now
bugs created Industry usually finds better writing
class at start
![Page 31: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/31.jpg)
1. Reexamine abstract nouns & keep if used in I/O
Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed.
Find Boundary Classes
![Page 32: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/32.jpg)
1. Reexamine abstract nouns & keep if used in I/O
Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed.
Find Boundary Classes
![Page 33: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/33.jpg)
2. Only use singular form of each noun
Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed.
Find Boundary Classes
![Page 34: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/34.jpg)
3.
Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed.
Find Boundary Classes
![Page 35: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/35.jpg)
3. There is no step 3
Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed.
Movement Request Illumination
I Know Boundary Classes!
![Page 36: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/36.jpg)
Control Classes
Non-obvious algorithms using many classes Rule of thumb: obvious algorithm have
name Control classes already exist for named
algorithms Needed for those plurals ignored
previously Can use array or enum, if exact number
known Else, design needs structure to hold
instances
![Page 37: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/37.jpg)
Control Classes
Non-obvious algorithms using many classes Rule of thumb: obvious algorithm have
name Control classes already exist for named
algorithms Needed for those plurals ignored
previously Can use array or enum, if exact number
known Else, design needs data structure to hold
instances
![Page 38: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/38.jpg)
Control Classes
Non-obvious algorithms using many classes Rule of thumb: obvious algorithm have
name Control classes already exist for named
algorithms Needed for those plurals ignored
previously Can use array or enum, if exact number
known Else, design needs data structure to hold
instances CSC212 & CSC213 focus: future control
classes CSC213 will discuss many “obvious”
algorithms Important data structures developed in both
courses
![Page 39: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/39.jpg)
1. Reexamine plurals & keep when necessary
Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed.
Finding Control Classes!
![Page 40: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/40.jpg)
1. Reexamine plurals & keep when necessary
Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed.
Finding Control Classes!
![Page 41: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/41.jpg)
2. Eliminate if constant number (array) needed
Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed.
Finding Control Classes!
![Page 42: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/42.jpg)
2. Eliminate if constant number (array) needed
Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed.
Finding Control Classes!
![Page 43: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/43.jpg)
2. Eliminate if constant number (array) needed
Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed.
Finding Control Classes!
![Page 44: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/44.jpg)
3. Select data structure to use for each plural
Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed.
Finding Control Classes!
![Page 45: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/45.jpg)
3. Select data structure to use for each plural
Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed.
PriorityQueue
Finding Control Classes!
![Page 46: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/46.jpg)
Now Determine Fields in Design Designing classes next step in process
For each class, determine fields Link classes that work together so easy to
code When done well, coding becomes relatively
simple What should be fields & how can we
know? Since they are abstract, boundary classes
often fields Control classes often fields; something
must use it Read text again: look where one noun
posses another
![Page 47: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/47.jpg)
What To Do Next?
Must communicate design in clear way to others Make explicit what the classes for this
program are Identify fields & other relationships
between classes Make certain information is clearly
highlighted Provides vital check that can often find
bugs Will do this by drawing pretty pictures
![Page 48: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/48.jpg)
What To Do Next?
Must communicate design in clear way to others Make explicit what the classes for this
program are Identify fields & other relationships
between classes Make certain information is clearly
highlighted Provides vital check that can often find
bugs Will do this by drawing pretty pictures
![Page 49: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/49.jpg)
Pictures Worth 1,000 Words
![Page 50: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/50.jpg)
Pictures Worth 1,000 Words
![Page 51: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/51.jpg)
Pictures Worth 1,000 Words
![Page 52: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/52.jpg)
Why Draw Classes?
Pictures used to share ideas easily Gets everyone up & coding at once
Group spends lab watching you code… …or get suckers to work while you relax
![Page 53: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/53.jpg)
Why Draw Classes?
Pictures used to share ideas easily Gets everyone up & coding at once
Group spends lab watching you code… …or get suckers teammates to work while
you relax
![Page 54: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/54.jpg)
Why Draw Classes?
Pictures used to share ideas easily Gets everyone up & coding at once
Group spends lab watching you code… …or get suckers teammates suckers to work while
you relax
![Page 55: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/55.jpg)
Why Draw Classes?
Pictures used to share ideas easily Gets everyone up & coding at once
Group spends lab watching you code… …or get suckers teammates suckers to work while
you relax Even better to get suckers working in
parallel
![Page 56: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/56.jpg)
Why Draw Classes?
Pictures used to share ideas easily Gets everyone up & coding at once
Group spends lab watching you code… …or get suckers teammates suckers to work while
you relax Even better to get suckers working in
parallel
![Page 57: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/57.jpg)
Why Draw Classes?
Pictures used to share ideas easily Gets everyone up & coding at once
Group spends lab watching you code… …or get suckers teammates suckers to work while
you relax Even better to get suckers working in
parallel Methods & their signatures included in
diagrams Can write code using all classes, even if
unwritten
![Page 58: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/58.jpg)
UML Class Diagrams
Classes drawn in 3-part box Class name written in top portion of box Attributes (fields) written in middle
portion Operations (methods) written in bottom
portion All variables written using following
format :name : type
Draw all important relationships within classes Inheritence & important fields normally
shown here Solid lines for classes and dashed lines for
interfaces
![Page 59: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/59.jpg)
Drawing Relationships
Must be able to explain all relationships
![Page 60: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/60.jpg)
Drawing Relationships
Must be able to explain all relationshipsBoyfriend-Girlfriend
Just FriendsFriends “with benefits”
Sweeties MarriedBest Friends
![Page 61: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/61.jpg)
Relationships From Fields
Aggregation Used for collection whose instances do not
rely on source Car aggregates CarParts (e.g., tires, engine,
lights…) Composition
Use when objects from target used only within source
Chessboard composes Squares Association
Source object has field of target type (not a collection)
Often used to imply source calls target's methods
![Page 62: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/62.jpg)
Playing “Utah Hold’Em”?
All of above relationships must be labeled Give field a name & show it near midpoint
of arrow Monogamous? Poly? Specify numbers
involved Each end of link has number involved on
that end Could be some range of numbers like ‘2..5’ + means 1 of more objects required to be
used Use Kleene’s star ‘*’ for 0 or more objects Specific number (1, 42, 69) good if
specifically known
![Page 63: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/63.jpg)
Generalization (“inheritance”) Shows subclass-superclass relationship Does not involve fields, multiplicities, or
anything else Makes this a different type of connection
than others Must draw all generalizations within the
diagram For implementation to be correct, these are
critical
Other Type of Connections
![Page 64: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/64.jpg)
Our “Final” Design Decisions
Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed.
![Page 65: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/65.jpg)
Elevator's UML Class Diagram
Note that Button class serves two purposes Direct travel to specific floor if in an
elevator Used on a floor to request travel up or
down Much easier with 2 subclasses of Button
![Page 66: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/66.jpg)
Elevator's UML Class Diagram
![Page 67: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/67.jpg)
Elevator's UML Class Diagram
2m-2 DirectionalButtons talk to n Elevators? But only 1 should respond; never use n-to-m
connection Who handles Requests? Need new class for
this!
![Page 68: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/68.jpg)
Elevator's UML Class Diagram
Next: where do methods come from?
![Page 69: CSC 213 – Large Scale Programming. Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods](https://reader036.vdocuments.us/reader036/viewer/2022070323/56649dc75503460f94abc188/html5/thumbnails/69.jpg)
For Next Lecture
Link to article for Monday on lecture page Reading for Monday available on Angel
What else can we do before coding? Are there more tricks that enables our
laziness? How to trick smarter suckers into doing our
work? Weekly assignment problem due in class
Mon. Weekly assignment page has problem for
today Noun extraction to find entity, boundary, &
control classes Show the connections by drawing UML class
diagram