Title: Jukebox Active Learning
1Object-Oriented Software Development
By Rick Mercer with help from these
sources Computing Fundamentals with C, Rick
Mercer Designing Object Oriented Software,
Rebbeca Wirfs-Brock, Wilkerson,
Wiener Object-Oriented Design Heuristics, Arthur
Riel
2Outline
- In the context of the Jukebox case study, follow
along as a team - analyzes a problem specification
- Designs a solution as a set of candidate objects
with well-defined responsibilities - Role plays different scenarios to understand the
problem and help make design decision - We'll also consider some design heuristics
3Goals of the OO Analysis
- 1. Identify candidate objects that model a system
as a sensible set of abstractions - 2. Determine the responsibility of each object
- what an instance of the class must be able to do,
- and what each instance must know about itself
- less important at first
- 3. Understand the system through role play
- To help complete its responsibility, an object
often needs help from other objects
4Analysis Tools
- Nouns (objects) Verbs (operations)
- Scenarios
- what happens when
- Role Playing
- team members become objects and do scenarios
- (C)andidate Object / (R)esponsibility/(C)ollaborat
or (CRC) cards - document candidate objects, assign
responsibilities, consider associations between
objects
5The Problem Specification
- The student affairs office want to put some
newfound activity fee funds toward a jukebox in
the student center. The jukebox must allow
students to play a song. No money will be
required. Instead, a student will swipe a
magnetic ID card through a card reader. Students
will each be allowed to play up to 1500 minutes
worth of "free" Jukebox music in their academic
careers, but never more than two selections on
any given date. The jukebox must make sure that
the same song is never played more than four time
a day (what a drag to hear "I Honestly Love You"
10 times) apologies to Olivia Newton John
61. Find the Objects
- Candidate objects may come from
- The problem statement
- An understanding of the problem domain
- knowledge of the system that the problem
specification may have missed or took for granted
- The words floating around the room while
analyzing the problem Alistair Cockburn - Object-Oriented Design Heuristic
- Model the real world whenever possible
7The Noun Phrases
- student affairs office
- activity fee funds
- music Jukebox
- money
- student center
- student
- student ID card
- card reader
- song
- minutes
- Jukebox music
- academic careers
- date
- selection
- CD
- collection of CDs
8A First Cut at the Candidate Objects (may become
classes)
- Jukebox
- Student
- Song
- Card reader
- Student ID card
- CD
- Collection of CDs
9Yesses
- Jukebox coordinates activities
- one instance to start things and keep them going
- JukeboxAccount (was Student) maintain one
account a model a user that can select - Song one song on a CD
- CardReader reads the magnetic ID card
10A No
- StudentIdCard store user data
- Object-Oriented Design Heuristic
- Eliminate classes that are outside the system
- The hallmark of such a class is one whose only
importance to the system is the data contained in
it. - Student identification number is of great
importance - The system should not care whether the ID number
was read from a swiped magnetic ID card, typed in
at the keyboard, or "if a squirrel arrived
carrying it in his mouth" Arthur Reil
11More Candidate Objects?
- CD store a collection of songs
- CdCollection stores a collection of CDs
- What about storing a collection of accounts?
- JukeBoxAccountCollection
- What about a compact disk player?
- CdPlayer plays the songs
- could have a software equivalent to talk to this
12Another No?
- StereoSystem Amplifies the music
- No, it's on the other side of the physical
CdPlayer - The next slide summarizes some needed candidate
objects - It also sets the boundaries of the system
- There are model of the real world objects
13Candidate Objects and the system boundary
CardReader Gets student ID
JukeboxAccountCollection Stores all
JukeboxAccount objects
JukeboxAccount
JukeBox Coordinates activities
CdCollection Stores all CDs that can be played
CD
CdPlayer Plays a song
CdTrack