Last GRASP (for now) and Use Case Realization · Use Case Realization The process of generating the...

23
Last GRASP (for now) and Use Case Realization Curt Clifton Rose-Hulman Institute of Technology

Transcript of Last GRASP (for now) and Use Case Realization · Use Case Realization The process of generating the...

Page 1: Last GRASP (for now) and Use Case Realization · Use Case Realization The process of generating the design model from use cases and other requirements artifacts Using GRASP and other

Last GRASP (for now)and Use Case RealizationCurt Clifton

Rose-Hulman Institute of Technology

Page 2: Last GRASP (for now) and Use Case Realization · Use Case Realization The process of generating the design model from use cases and other requirements artifacts Using GRASP and other

General,Responsibility AssignmentSoftware Patterns Principles

Page 3: Last GRASP (for now) and Use Case Realization · Use Case Realization The process of generating the design model from use cases and other requirements artifacts Using GRASP and other

Coupling

A measure of how strongly one element is connected to, has knowledge of, or relies on other elements

Want low (or weak) coupling

An evaluative principle

Page 4: Last GRASP (for now) and Use Case Realization · Use Case Realization The process of generating the design model from use cases and other requirements artifacts Using GRASP and other

Cohesion

A measure of how strongly related and focused the responsibilities of a class (or method or package…) are

Want high cohesion

An evaluative principle

Page 5: Last GRASP (for now) and Use Case Realization · Use Case Realization The process of generating the design model from use cases and other requirements artifacts Using GRASP and other

Information Expert

Problem: What is the most general principle of assigning responsibilities?

Solution: Assign a responsibility to the class that has the necessary information

Page 6: Last GRASP (for now) and Use Case Realization · Use Case Realization The process of generating the design model from use cases and other requirements artifacts Using GRASP and other

Creator

Problem: Who should be responsible for creating a new instance of some class?

Solution: Make B responsible for creating A if…

B contains or is a composition of A

B records A

B closely uses A

B has the data to initialize AThe more matches

the better.

Most important

Page 7: Last GRASP (for now) and Use Case Realization · Use Case Realization The process of generating the design model from use cases and other requirements artifacts Using GRASP and other

Team Creativity

Q11

Page 8: Last GRASP (for now) and Use Case Realization · Use Case Realization The process of generating the design model from use cases and other requirements artifacts Using GRASP and other

Controller

Page 9: Last GRASP (for now) and Use Case Realization · Use Case Realization The process of generating the design model from use cases and other requirements artifacts Using GRASP and other

Controller

Problem: What first object beyond the UI layer receives and coordinates a system operation

Solution: Assign the responsibility to either…

A façade controller, representing the overall system and handling all system operations, or

A use case controller, that handles all system events for a single use case

What’s that?

Q12,13Not JFrame, not JPanel, …

Page 10: Last GRASP (for now) and Use Case Realization · Use Case Realization The process of generating the design model from use cases and other requirements artifacts Using GRASP and other

Example

What domain layer class should own handling of the enterItem system operation?

Page 11: Last GRASP (for now) and Use Case Realization · Use Case Realization The process of generating the design model from use cases and other requirements artifacts Using GRASP and other

Guidelines

Controller should delegate to other domain layer objects

Use a façade controller when…

There are a limited number of system operations, or

When operations are coming in over a single “pipe”

Use a use case controller when a façade would be bloated (low cohesion!)

Page 12: Last GRASP (for now) and Use Case Realization · Use Case Realization The process of generating the design model from use cases and other requirements artifacts Using GRASP and other

Controller Benefits

Increased potential for reuse

Can reason/control the state of a use case

E.g., don’t close sale until payment is accepted

Page 13: Last GRASP (for now) and Use Case Realization · Use Case Realization The process of generating the design model from use cases and other requirements artifacts Using GRASP and other

Controller Issues

Controller bloat—too many system operations

Controller fails to delegate tasks

Controller has many attributes

Switch from façade to use case controllers

Delegate!

Page 14: Last GRASP (for now) and Use Case Realization · Use Case Realization The process of generating the design model from use cases and other requirements artifacts Using GRASP and other

Team Control

Q14,15

Page 15: Last GRASP (for now) and Use Case Realization · Use Case Realization The process of generating the design model from use cases and other requirements artifacts Using GRASP and other

Cartoon of the Day

Jan 4, 2010. Used by permission

Page 16: Last GRASP (for now) and Use Case Realization · Use Case Realization The process of generating the design model from use cases and other requirements artifacts Using GRASP and other

Use Case Realization

Page 17: Last GRASP (for now) and Use Case Realization · Use Case Realization The process of generating the design model from use cases and other requirements artifacts Using GRASP and other

Use Case Realization

The process of generating the design model from use cases and other requirements artifacts

Using GRASP and other patterns to guide decisions

Page 18: Last GRASP (for now) and Use Case Realization · Use Case Realization The process of generating the design model from use cases and other requirements artifacts Using GRASP and other

Use Cases…

Drove the development of

Domain Model

System Sequence Diagrams

Operation Contracts

Page 19: Last GRASP (for now) and Use Case Realization · Use Case Realization The process of generating the design model from use cases and other requirements artifacts Using GRASP and other

System Sequence Diagrams

Helped us identify system operations

Use these to begin interaction diagrams

System operations are the starting messages

Starting messages are directed at controller objects

Q1

Page 20: Last GRASP (for now) and Use Case Realization · Use Case Realization The process of generating the design model from use cases and other requirements artifacts Using GRASP and other

Operation Contracts

Defined post-conditions of system operations as changes to objects/associations in the domain model

Use post-conditions to help determine…

What should happen in the interaction diagrams

What classes belong in the design class diagram

Also often discover classes that were missed in the domain model Q2

Page 21: Last GRASP (for now) and Use Case Realization · Use Case Realization The process of generating the design model from use cases and other requirements artifacts Using GRASP and other

Where to Begin

In code, begin at the beginning

In design, defer design of the Start Up use case

Why?

Q3

Page 22: Last GRASP (for now) and Use Case Realization · Use Case Realization The process of generating the design model from use cases and other requirements artifacts Using GRASP and other

Example (if time permits)

Page 23: Last GRASP (for now) and Use Case Realization · Use Case Realization The process of generating the design model from use cases and other requirements artifacts Using GRASP and other

Design makeNewSale

Operation:

Cross References:

Preconditions:

Postconditions:

makeNewSale()

Use Case: Process Sale

none

A Sale instance s was createds was associated with the RegisterAttributes of s were initialized