Chapter 1
description
Transcript of Chapter 1
![Page 1: Chapter 1](https://reader035.fdocuments.us/reader035/viewer/2022070423/568167f2550346895ddd657e/html5/thumbnails/1.jpg)
Chapter 1
![Page 2: Chapter 1](https://reader035.fdocuments.us/reader035/viewer/2022070423/568167f2550346895ddd657e/html5/thumbnails/2.jpg)
Software Engineering vs OOD:
• Software Engineering– What needs to be done– Who does it– When is it done
• OOD– What needs to be done– What classes are responsible for doing it– What classes have the job of seeing it gets done
![Page 3: Chapter 1](https://reader035.fdocuments.us/reader035/viewer/2022070423/568167f2550346895ddd657e/html5/thumbnails/3.jpg)
UML vs Thinking in Objects:
• UML (Unified Modeling Language) is just a language; not a method or a methodology
• Most of our UML will be pencil-and-paper• This course is about OOD/A –
Object-Oriented Design/Analysis• What classes?• What responsibilities to what classes?
“Responsibility-driven design”• Patterns as guide posts. These are named solution
formulas
![Page 4: Chapter 1](https://reader035.fdocuments.us/reader035/viewer/2022070423/568167f2550346895ddd657e/html5/thumbnails/4.jpg)
Case Studies:
• There are two followed in this book– NextGen POS (Point-of-Sale)– Monopoly
![Page 5: Chapter 1](https://reader035.fdocuments.us/reader035/viewer/2022070423/568167f2550346895ddd657e/html5/thumbnails/5.jpg)
Use Cases
• Where ever you find OOD, you also fine Requirements Analysis– What does the customer want?– How to capture the customer needs?
• UML offers Use Cases (Chapter 6) to capture customer requirements– Use cases expressed in pictures and text.– Use case pictures use stick figures for human agents,
boxes for software agents, circles for processes– Use case text is a line-by-line description of the user
activity.
![Page 6: Chapter 1](https://reader035.fdocuments.us/reader035/viewer/2022070423/568167f2550346895ddd657e/html5/thumbnails/6.jpg)
Example: Password Verification (Use Case Diagram)
User
verify password
PV System
password database
** *
*
software system boundary
enters userID/passwd
verifies passwd against db
![Page 7: Chapter 1](https://reader035.fdocuments.us/reader035/viewer/2022070423/568167f2550346895ddd657e/html5/thumbnails/7.jpg)
Example: Password Verification (Use Case Text)• Scenario 1 (Success):
– user enters userID– user enters password– password checked against password database– password valid, user set to go
• Scenario 2 (Failure):– user enters userID– user enters password– password fails to check out against password
database– password invalid, user prompted to reenter password– After third successive failure, program aborts.
![Page 8: Chapter 1](https://reader035.fdocuments.us/reader035/viewer/2022070423/568167f2550346895ddd657e/html5/thumbnails/8.jpg)
Homework #1: Due next class
• Expand the Password Verification Use Case Diagram and Text to show more detail (include use of cookie to retrieve previously saved password cookie). Do not bother with the cookie generation Use Case.
![Page 9: Chapter 1](https://reader035.fdocuments.us/reader035/viewer/2022070423/568167f2550346895ddd657e/html5/thumbnails/9.jpg)
Agile Software Development• Processes
– emphasize teamwork– work hand-in-hand with users– design for change– frequent delivery of small increments in short
iterations• Values
– individuals and interactions over processes and tools– working software over comprehensive
documentation– customer collaboration over contract negotiation– responding to change over following a plan
![Page 10: Chapter 1](https://reader035.fdocuments.us/reader035/viewer/2022070423/568167f2550346895ddd657e/html5/thumbnails/10.jpg)
Agile Software Development • Principles
– active user involvement– team empowered to make decisions– requirements evolve but timescale is fixed– requirements at high-level– small incremental releases– frequent delivery of working software– complete something before moving on– follow 80-20 rule: 80% of productivity comes from 20%
of software so do that first– test early and often– collaboration and cooperation is essential
![Page 11: Chapter 1](https://reader035.fdocuments.us/reader035/viewer/2022070423/568167f2550346895ddd657e/html5/thumbnails/11.jpg)
Interactive Development and Agile Modeling
• In this book we learn an agile approach to the Unified Process (UP), a well-known, iterative software development process.
• The next slide shows the topics and skills covered by this course.
• Homework# 2: Write a page describing the differences and similarities between agile programming, extreme programming and the unified process.
![Page 12: Chapter 1](https://reader035.fdocuments.us/reader035/viewer/2022070423/568167f2550346895ddd657e/html5/thumbnails/12.jpg)
Fig. 1.1
Topics and Skills
UML notation
Requirements analysis
Principles and guidelines
Patterns
Iterative development with an agile Unified
Process
OOA/D
![Page 13: Chapter 1](https://reader035.fdocuments.us/reader035/viewer/2022070423/568167f2550346895ddd657e/html5/thumbnails/13.jpg)
“Desert Island” Skill
• What is the most important OOD/A skill?Responsibility Assignment
• sooner or later, must be done,• influences robustness, maintainability and reusability• hard to master• if done early, hard to choose from options• may be the only “design” activity performed• Text presents nine fundamental principals of OD and RA
the author calls GRASP.
![Page 14: Chapter 1](https://reader035.fdocuments.us/reader035/viewer/2022070423/568167f2550346895ddd657e/html5/thumbnails/14.jpg)
Exercise:
• Consider a library situation in which electronic documents belonging to a library (such as e-books) are checked out to library patrons (onto their iPads or Kindle devices).
• Consider the following responsibilities and decide what classes of an eventual programmed implementation of this process should have what responsibilities:
– determine document availability– create a document loan specifying which
document and which patron– retrieve document in preparation for making a
loan– save the completed loan.
![Page 15: Chapter 1](https://reader035.fdocuments.us/reader035/viewer/2022070423/568167f2550346895ddd657e/html5/thumbnails/15.jpg)
What is Analysis and Design
• Analysis: – investigate problem and is requirements; solution
comes later– ask and answer questions– Example: Grade Book. Some questions?– Requirements Analysis
• investigate requirements– Object-oriented Analysis
• investigate objects used in and by domain
![Page 16: Chapter 1](https://reader035.fdocuments.us/reader035/viewer/2022070423/568167f2550346895ddd657e/html5/thumbnails/16.jpg)
What is Analysis and Design
• Design: – a conceptual solution that fulfills requirements– exclude implementation detail; not an implementation– Example: Database. A schema– Requirements Analysis
• investigate requirements– Object-oriented Analysis
• investigate objects used in and by domain
![Page 17: Chapter 1](https://reader035.fdocuments.us/reader035/viewer/2022070423/568167f2550346895ddd657e/html5/thumbnails/17.jpg)
Fig. 1.2
Plane
tailNumber
public class Plane{private String tailNumber;
public List getFlightHistory() {...}}
domain conceptvisualization of domain concept
representation in an object-oriented programming language
notes in UML
![Page 18: Chapter 1](https://reader035.fdocuments.us/reader035/viewer/2022070423/568167f2550346895ddd657e/html5/thumbnails/18.jpg)
A Short Example
• Dicey: In which a program simulates a player tossing two dice.
• Define Use Cases– these are user scenarios, stories, goals
• Define a Domain Model– this is a description of the domain from the point of
view of the objects involved– identify the concepts, attributes and associations– result is called the domain model
Play a Dice Game Use Case: Player requests a roll of the dice. System presents results:If dice show 7 player wins; otherwise player loses
![Page 19: Chapter 1](https://reader035.fdocuments.us/reader035/viewer/2022070423/568167f2550346895ddd657e/html5/thumbnails/19.jpg)
Fig. 1.3
Player
name
DiceGame
Die
faceValue
Rolls
Plays
Includes
2
2
1
1
1
1
Partial (Conceptual) Domain Model
not descriptive of the softwareobjects but rather of the domain
![Page 20: Chapter 1](https://reader035.fdocuments.us/reader035/viewer/2022070423/568167f2550346895ddd657e/html5/thumbnails/20.jpg)
Assigning Responsibilities
• In a program, objects collaborate – pass each other messages, make data available to one another
• Common notation is called a sequence diagram.• A sequence diagram shows the flow of messages
between objects• If we know where the message goes we know who is
“responsible” for “responding to” the message.• Answering the message involves knowing “how” to
answer the message• How close is “flow of message” to the concept of
“function call”?
![Page 21: Chapter 1](https://reader035.fdocuments.us/reader035/viewer/2022070423/568167f2550346895ddd657e/html5/thumbnails/21.jpg)
Fig. 1.4
![Page 22: Chapter 1](https://reader035.fdocuments.us/reader035/viewer/2022070423/568167f2550346895ddd657e/html5/thumbnails/22.jpg)
Fig. 1.4
:DiceGame
play()
die1 : Die
fv1 := getFaceValue()
die2 : Die
roll()
roll()
fv2 := getFaceValue()
time
![Page 23: Chapter 1](https://reader035.fdocuments.us/reader035/viewer/2022070423/568167f2550346895ddd657e/html5/thumbnails/23.jpg)
Example:
• Break into teams and design a Sequence Diagram for a student registering for a course.
• Basic activity – suggest some classes and how they might collaborate.
• Don't be afraid to break a complex system into several sequence diagrams.
![Page 24: Chapter 1](https://reader035.fdocuments.us/reader035/viewer/2022070423/568167f2550346895ddd657e/html5/thumbnails/24.jpg)
Defining Classes
• The preceding is a dynamic view of collaborating classes• The following is a static view of collaborating classes;
more often called a class diagram.• Differs from the domain model, with similarities.• Follows the sequence diagram in the order of things.
![Page 25: Chapter 1](https://reader035.fdocuments.us/reader035/viewer/2022070423/568167f2550346895ddd657e/html5/thumbnails/25.jpg)
Fig. 1.5
2
Die
faceValue : int
getFaceValue() : introll()
DiceGame
die1 : Diedie2 : Die
play()
1
![Page 26: Chapter 1](https://reader035.fdocuments.us/reader035/viewer/2022070423/568167f2550346895ddd657e/html5/thumbnails/26.jpg)
Bridging the Gap
RealWorld
DesignObjectDomainObject Program
DefiningDomainModel DesigningClasses Coding
RealWorld
Entity-RelationshipModel
Relational Data Model
Database
![Page 27: Chapter 1](https://reader035.fdocuments.us/reader035/viewer/2022070423/568167f2550346895ddd657e/html5/thumbnails/27.jpg)
What is UML?
• The Unified Modeling Language is a visual language for specifying, construction and documenting the artifacts of systems. (OMG)
• A lot more than we ever need to know including lots of software for drawing pictures (our department gives away Visio free to students).
“I very rarely use UML tools ” Craig Larman
![Page 28: Chapter 1](https://reader035.fdocuments.us/reader035/viewer/2022070423/568167f2550346895ddd657e/html5/thumbnails/28.jpg)
How to Apply UML?
• As a sketch: informal, hand-drawn documents, used for exploration
• As a blueprint: detailed design documents, developed by tools that either forward- or reverse engineer code.– forward: tool takes a picture and produces executable
code (mostly stubs).– reverse: tool takes executable code and draws a
picture.• As a Programming Language: Tools produce complete
executables.• Ala Agile Programming: UML as a sketch.
author’s preference
![Page 29: Chapter 1](https://reader035.fdocuments.us/reader035/viewer/2022070423/568167f2550346895ddd657e/html5/thumbnails/29.jpg)
Three Perspectives in Applying UML
• UML does not dictate modeling perspective; you can use a class diagram for real-world concepts or Java classes.
• None the less, perspectives exist:– Conceptual: Describe the real world– Specification (software): Describe software
abstractions using specs or interfaces – no commitment to a particular implementation
– Implementation (software): Describe an implementation in a particular language.
![Page 30: Chapter 1](https://reader035.fdocuments.us/reader035/viewer/2022070423/568167f2550346895ddd657e/html5/thumbnails/30.jpg)
Fig. 1.6
Conceptual Perspective(domain model)
Raw UML class diagram notation used to visualize real-world concepts.
Specification or Implementation
Perspective(design class diagram)
Raw UML class diagram notation used to visualize software elements.
2
Die
faceValue : int
getFaceValue() : introll()
DiceGame
die1 : Diedie2 : Die
play()
DiceGame Die
faceValue
Includes 21
![Page 31: Chapter 1](https://reader035.fdocuments.us/reader035/viewer/2022070423/568167f2550346895ddd657e/html5/thumbnails/31.jpg)
Different Perspectives of “Class”.
• Rectangular boxes are classes. But they can be physical things, abstract concepts, software things, events, …
• A software design methods or methodologies superimposes structure/naming conventions on the various UML objects.
• For example, in the Unified Process (UP), Domain Model, a box represents a conceptual class. In the Design Model they are called Design Classes.
• Our book follows UP:– conceptual class, software class, implementation
class.
![Page 32: Chapter 1](https://reader035.fdocuments.us/reader035/viewer/2022070423/568167f2550346895ddd657e/html5/thumbnails/32.jpg)
Visual Modeling is a Good Thing
• Diagrams help our understanding of things.• Text is not easy to learn from, it is so linear.• A picture is worth a thousand words.
Exercise:• Read the last section on history of UML