MartinFowlerAnalysisPatterns PDF
MartinFowlerAnalysisPatterns PDF
Martin Fowler
fowler@
[email protected]
acm.org
http://ourworld
http://ourworld..compuserve.com/homepages/Martin_Fowler
compuserve.com/homepages/Martin_Fowler
Introduction
Observation
Patterns
Accounting
Patterns
How to use
Patterns
1
Patterns
…projects fail despite the latest technology
for lack of ordinary solutions.
http://www.hillside.net/patterns
Concrete Colleague
Concrete Mediator
Concrete Colleague
q Define an object
that encapsulates
how a set of objects
interact.
Gamma, E., Helm, R., Johnson, R. and Vlissides, J. Design
Patterns: elements of reusable object-oriented software,
Addison-Wesley, Reading, MA, 1995.
www.industriallogic.com/papers/learning.html
Page 4 © Martin Fowler 9/11/99
2
Analysis Patterns
q David Hay
â Relational data models
â Not connected with
patterns community, but
still patterns
â Hay, D. Data Model
Patterns: conventions of
thought, Dorset House,
New York, NY, 1996.
q Martin Fowler
â OO conceptual models
â Healthcare, Accounting,
Financial Trading, Planning
â Fowler, M. Analysis
Patterns: reusable object
models, Addison-Wesley,
Reading MA, 1997.
Page 5 © Martin Fowler 9/11/99
Notation
Each customer Each order
may have has a single
many orders customer
Order
Customer placedOn : Date
1 [
dispatch()
Priority
Order
Individual Corporate
Customer Customer An order
may be a
priority order
A customer may be a
corporate customer or an
individual customer
3
Patterns in 3 tier architecture
application
1
application
domain database
2
application
3
Observation Patterns
Introduction
Observation
Patterns
Accounting
Patterns
How to use
Patterns
4
Attributes of Person
Person
height : Number
weight : Number
blood glucose level : Number
Quantity
Quantity
amount: Number
Person
units: Unit
height : Quantity
weight : Quantity +, -, *, /
blood glucose level : Quantity <, >, =, <=, >=
as(Unit) : Quantity
toString() : String
valueOf(String) : Quantity
5
Measurement
Phenomenon Type
[
Person
[ Measurement
Observation
1
Phenomenon Phenomenon Type
[
1 1
[
Category
Observation
[
Observation
Measurement
{overlapping}
[ amount: Quantity
1
Person
amountOf(PhenomenonType) : Quantity
valueOf(PhenomenonType) : Phenomenon
6
Knowledge and Operational Levels
arguments
[ [
Associative
Phenomenon
Function
[ 1
result
1
Knowledge
Operational
[
Category
Person Observation
Observation
1 [
q Operational
â regular day to day objects
q Knowledge
â Meta-Data
â Objects that capture domain rules
Page 13 © Martin Fowler 9/11/99
Range
Range Magnitude
upper: Magnitude
lower: Magnitude =
isUpperInclusive: Boolean <
isLowerInclusive: Boolean =<
>
includes (Magnitude) : Boolean >=
overlaps (Range) : Boolean
abuts (Range) : Boolean
7
Phenomenon with Range
1
Range Phenomenon
1
Phenomenon
{phenomena's ranges
Type
should not overlap}
Assigning a phenomenon
new heart rate: normal heart rate: fast heart rate:
a Measurement
Phenomenon Type Phenomenon Phenomenon
phenomenon = phenomenonIncluding(aMeasurement)
includes (aMeasurement)
false
includes (aMeasurement)
true
fastHeartRate
setPhenomenon(fastHeartRate)
8
Corporate Finance Problem
Measurement Protocol
[ 1 Measurement [ 1 Phenomenon
Measurement
Protocol {list} Type
Source
Calculated
Measurement
Measurement
Protocol
Protocol
9
Calculated Measurement
result type
Measurement 1 Phenomenon
Protocol [ Type
Creating a Measurement
a Measurement
a Formula
Protocol
create Measurement
find arguments
execute
return quantity
new
a Measurement
10
Observation Patterns
q Quantity
q Measurement
q Observation
q Range
q Phenomenon with Range
q Measurement Protocol
Accounting Patterns
Introduction
Observation
Patterns
Accounting
Patterns
How to use
Patterns
11
Account
Entry
Account
amount: Money
balance: Money 1 [ whenCharged: Timepoint
whenBooked: Timepoint
{balance = sum(entries)}
Transaction
Entry
1 [ amount: Money 2..[ 1
Account Transaction
{sum(entries.amount) = 0}
12
Posting Rule (simple)
Posting Rule
1
Account multiplier: Number
output
execute()
1
trigger
Posting Rule
1 Method
calculation
Account …
13
Account Types
output 1
Account Type Posting Rule Method
[
1 1
trigger
Knowledge
Operational
[
Employee
1
Employee
Account [
- Apply the graduated tax algorithm to the gross pay of Doug and
Dinsdale Piranha to yield their net pay.
straight += input
OT hours PR if (Sunday) excess += input
else excess += input * 0.5
excess = input *
employee.otRate * 2/3
premium = input *
employee.otRate * 1/3
Straight OT Payment out = input * Excess Payment:
: Posting Rule employee.rate Posting Rule
Total Overtime :
$225 Summary Account
Type
14
Executing the network
a list of Posting Rules a Posting Rule an Employee input Account output Account
Procedural Approach
H
H
get unprocessed
Dollarize Straight entries
Hours
multiply by rate
Dollarize Excess
Hours
H post to straight
dollars
15
Changing the Rules
H
H
get unprocessed
Dollarize Straight entries
Hours
post to straight
dollars
Posting Rule
output 1
Account Type effectivity: Date Range Method
[
1 1
trigger
[
Employee
1
Employee
Account [
16
New Behavior
a list of Posting Rules a Posting Rule an Employee input Account output Account
17
Strategy Pattern
{abstract}
State Tax PR Calculation Strategy
1
state: State
calculate() calculate()
«Method»
return strategy.calculate()
Parameterized Method
State Tax PR
state: State
rate: Number
calculate() «Method»
multiply by rate
18
Combining Implementations
State Tax PR
state: State
calculate()
{Singleton} {Singleton}
CA Tax PR Multiplier PR NYTax PR
rate: Number
19
Accounting Patterns
q Account
q Transaction
q Posting Rule
q Individual Instance Method
q Posting Rule Execution
q Posting Rules for Many Accounts
q Accounting Practice
Introduction
Observation
Patterns
Accounting
Patterns
How to use
Patterns
20
Using Patterns
q Starting point for development
â Inspiration to get things going
q Comparison for review
â Why are we different to this pattern?
q Documentation of complex frameworks
â Highlight the key patterns
q Informal standardization
q Mining from legacy systems
q Training
â The next step after basic training
http://www.hillside.net/patterns
21
Books
q Beck, K. Smalltalk Best Practice Patterns. Volume 1: Coding,
Prentice Hall, Englewood Cliffs, NJ, 1997.
q Buschmann, F., Meunier, R., Rohnert, H., Sommerlad, P. and
Stal., M. Pattern-Oriented Software Architecture - A System of
Patterns, John Wiley, 1996.
q Coad, P., North, D. and Mayfield, M. Object Models: strategies,
patterns and applications, Prentice Hall, Englewood Cliffs,
1995.
q Coplien, J.O. and Schmidt, D.C. Pattern Languages of Program
Design, Addison-Wesley, Reading, MA, 1995.
q Gamma, E., Helm, R., Johnson, R. and Vlissides, J. Design
Patterns: elements of reusable object-oriented software,
Addison-Wesley, Reading, MA, 1995.
q Fowler, M. Analysis Patterns, Addison-Wesley, Reading MA,
1997
q Hay, D. Data Model Patterns: conventions of thought, Dorset
House, New York, NY, 1996.
q Vlissides, J.M., Coplien, J.O. and Kerth, N.L. ed.Pattern
Languages of Program Design 2, Addison-Wesley, 1996.
http://www.hillside.net/patterns
Final Thoughts
q Patterns are relevant for all aspects of
software engineering
â and for Business Process Reengineering
q Analysis patterns can be used across
traditional vertical business domains
q A model is not right or wrong, only more
or less useful
q Patterns are a starting point, not a final
destination
q Still learning about teaching, using, and
discovering patterns
22