big java chapter 12. software process - waterfall analysis design implementation testing deployment...
TRANSCRIPT
Big JavaBig JavaChapter 12Chapter 12
Software Process - WaterfallSoftware Process - Waterfall
Analysis
Design
Implementation
Testing
Deployment
Does not work well whenrigidly applied!
established early 1970s
What do customers really want?
Design not very efficient, but oh wellInconsistentrequirements?
Customers not happy
Software Process – Spiral*Software Process – Spiral*
Implementation
Testing
Deployment
prototype #1
prototype #2
final product
Analysis
Design
*should be spirals, not circles, but no arcs in PP
implement prototypes quickly
Issue: s/w engineers maythink there will always be another iteration, don’t deliver quality
Reading AssignmentReading Assignment
• Random Fact 12.1, Programmer Productivity, page 535
Discovering ClassesDiscovering Classes
Required tasks:1. Discover classes2. Determine responsibilities of each class3. Describe relationships between classes
We’ve already talked about using nouns as possible classes/objects and verbs as the possible methods.
Points to ConsiderPoints to Consider• A class represents a set of objects with the same
behavior. The design should capture the commonalities.
• Some entities will be objects, others will be primitive types. How to decide? Example: an address could either be a simple string or a class. If your system needs to do special processing on the address, a class may be called for. Otherwise, keep it simple.
• Not all classes will be discovered in analysis phase. Most systems have extra classes for tactical purposes, such as database access, GUI, etc.
• Use existing classes, extended as needed, where you can.
Assigning methods - CRCAssigning methods - CRC
• Sometimes it is difficult to determine which class should implement a particular method.
• CRC card method – Classes, Responsibilities, Collaborators– Use index card for each class– Write responsibilities on the class card– Also record which other classes are needed to
fulfill that task (collaborators)
CRC ExampleCRC Example
Invoice
compute amount due LineItem
Responsibilities Collaborators
Does this class have neededmethods? such as getTotalPrice?
Tasks can be simulated by moving tokens from one card to the next as objects are called on to do their methods
These should be high level
Class RelationshipsClass Relationships
• Be sure inheritance really represents is-a relationships. Is a tire a circle? No, tire is a car part; circle is a geometric object. A tire has a circle as its boundary. public class Tire
{
…
private Circle boundary;
}
• This type of relationship is called aggregation.
Another exampleAnother example
public class Car extends Vehicle
{
…private Tire[] tires;
}
is-a (inheritance)
has-a (aggregation)Vehicle
Car
Tire
UML Symbols
InheritanceInterface ImplementationAggregationDependency
More UMLMore UML
• UML class diagrams may list attributes (often instance variables) and methods. Actual class may not store data that way (e.g., Date class stores as # milliseconds, but has day, month and year attributes)
• May not list all attributes and methods, depends on purpose of diagram
• Don’t list as attribute if also an aggregation• May show multiplicities for aggregates
– any number : *– one or more: 1..*– zero or one: 0..1– exactly one: 1
Cluttered picture notvery valuable!
AssociationAssociation
• Sometimes “has” doesn’t really represent relationship
• Does bank “have” customers, do customers “have” bank?
• More general relationship is association• Use solid line with arrows to show that it’s
possible to navigate from objects of one class to objects of another
• May add text to explain relationship (e.g., serves on line from Bank to Customer)
• Association vs Aggregation not an important distinction – use it if it helps make design clearer!
More UML ExamplesMore UML Examples
Customer BankAccount1..*
CustomerBankserves
Bank Account
balance
deposit()withdraw()
CRC Exercise PreparationCRC Exercise Preparation
• Reading Assignment: Case Study pages 544-556, Printing an Invoice
• Reading Assignment: Case Study pages 556-577, ATM
ATM case study shows UML and also state diagrams (next two slides)
• Exercise on ThursdayIMPORTANT! Allocate10 minutes to readthe case studies beforethe exercise on Thursday.Bring your stories!!!
ATM State DiagramATM State Diagram
Start
PIN
Account
Transact
Customer number entered
Customer foundCustomernot found
Exit selectedAccount selected
Transaction completedor canceled
ATM UMLATM UML
ATMFrame
Keypad
ATM Bank
Customer
BankAccount
1
1
1
2
*
Does the ATM aggregate customers? – design decision
GUIclasses
ATM Case StudyATM Case Study
ATM
manage state Customer
select customer
select account
execute transaction
Bank
BankAccount
CRC ExerciseCRC Exercise
• Apply the CRC method to develop classes for the stories you wrote in the previous exercise
• Create UML diagrams for those classes