18
Big Java Big Java Chapter 12 Chapter 12

Big Java Chapter 12. Software Process - Waterfall Analysis Design Implementation Testing Deployment Does not work well when rigidly applied! established

Embed Size (px)

Citation preview

Page 1: Big Java Chapter 12. Software Process - Waterfall Analysis Design Implementation Testing Deployment Does not work well when rigidly applied! established

Big JavaBig JavaChapter 12Chapter 12

Page 2: Big Java Chapter 12. Software Process - Waterfall Analysis Design Implementation Testing Deployment Does not work well when rigidly applied! established

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

Page 3: Big Java Chapter 12. Software Process - Waterfall Analysis Design Implementation Testing Deployment Does not work well when rigidly applied! established

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

Page 4: Big Java Chapter 12. Software Process - Waterfall Analysis Design Implementation Testing Deployment Does not work well when rigidly applied! established

Reading AssignmentReading Assignment

• Random Fact 12.1, Programmer Productivity, page 535

Page 5: Big Java Chapter 12. Software Process - Waterfall Analysis Design Implementation Testing Deployment Does not work well when rigidly applied! established

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.

Page 6: Big Java Chapter 12. Software Process - Waterfall Analysis Design Implementation Testing Deployment Does not work well when rigidly applied! established

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.

Page 7: Big Java Chapter 12. Software Process - Waterfall Analysis Design Implementation Testing Deployment Does not work well when rigidly applied! established

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)

Page 8: Big Java Chapter 12. Software Process - Waterfall Analysis Design Implementation Testing Deployment Does not work well when rigidly applied! established

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

Page 9: Big Java Chapter 12. Software Process - Waterfall Analysis Design Implementation Testing Deployment Does not work well when rigidly applied! established

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.

Page 10: Big Java Chapter 12. Software Process - Waterfall Analysis Design Implementation Testing Deployment Does not work well when rigidly applied! established

Another exampleAnother example

public class Car extends Vehicle

{

…private Tire[] tires;

}

is-a (inheritance)

has-a (aggregation)Vehicle

Car

Tire

UML Symbols

InheritanceInterface ImplementationAggregationDependency

Page 11: Big Java Chapter 12. Software Process - Waterfall Analysis Design Implementation Testing Deployment Does not work well when rigidly applied! established

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!

Page 12: Big Java Chapter 12. Software Process - Waterfall Analysis Design Implementation Testing Deployment Does not work well when rigidly applied! established

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!

Page 13: Big Java Chapter 12. Software Process - Waterfall Analysis Design Implementation Testing Deployment Does not work well when rigidly applied! established

More UML ExamplesMore UML Examples

Customer BankAccount1..*

CustomerBankserves

Bank Account

balance

deposit()withdraw()

Page 14: Big Java Chapter 12. Software Process - Waterfall Analysis Design Implementation Testing Deployment Does not work well when rigidly applied! established

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!!!

Page 15: Big Java Chapter 12. Software Process - Waterfall Analysis Design Implementation Testing Deployment Does not work well when rigidly applied! established

ATM State DiagramATM State Diagram

Start

PIN

Account

Transact

Customer number entered

Customer foundCustomernot found

Exit selectedAccount selected

Transaction completedor canceled

Page 16: Big Java Chapter 12. Software Process - Waterfall Analysis Design Implementation Testing Deployment Does not work well when rigidly applied! established

ATM UMLATM UML

ATMFrame

Keypad

ATM Bank

Customer

BankAccount

1

1

1

2

*

Does the ATM aggregate customers? – design decision

GUIclasses

Page 17: Big Java Chapter 12. Software Process - Waterfall Analysis Design Implementation Testing Deployment Does not work well when rigidly applied! established

ATM Case StudyATM Case Study

ATM

manage state Customer

select customer

select account

execute transaction

Bank

BankAccount

Page 18: Big Java Chapter 12. Software Process - Waterfall Analysis Design Implementation Testing Deployment Does not work well when rigidly applied! established

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