Transcript hints-5

Hints - Mandatory 5
Blackbox Testing
Pattern Hunting
The UML Trap
… which several TAs have fallen into…
What is UML ?
– 1) A visual representation of a program
– 2) A visual language for expressing architecture
Henrik Bærbak Christensen
2
Then what is this?
1) An interface with a reference to an interface
– Can we do that in Java?
Henrik Bærbak Christensen
3
And in Python
Python has no interface language construct
– But is an OO language
Python uses ‘duck typing’
– Suitability is determined by the presence of methods,
not by the object’s type
Henrik Bærbak Christensen
4
And in Python
Python has no interface language construct
– But is an OO language
Can I realize this architecture in Python?
Henrik Bærbak Christensen
5
It is not a problem
Just more ‘docs and conventions’
Henrik Bærbak Christensen
6
The PayStation
Henrik Bærbak Christensen
7
And The Strategies
I dealy miss my declared interface!
– But ‘if it calculates time, it is a RateStrategy’
Henrik Bærbak Christensen
8
The Bottom Line
In FRS, UML expresses architecture
Any implementation of PayStation ever must
have a relation to a RateStrategy!
– It is my architectural decision, and binds any who
implements PayStation!
Henrik Bærbak Christensen
9
The Other Way
If I had made the binding on PayStationImpl
– PayStationImpl <>---- RateStrategy
What had I then expressed as an architect???
Any Suggestions…
Henrik Bærbak Christensen
10
The TA Confusion
Several hand-ins have been rejected that drew
aggregations between Game interface and e.g.
WinnerStrategy interfaces.
–
TAs are humans and make mistakes 
– (Even the lecturer makes mistakes )
Talk to me and the TAs…
Henrik Bærbak Christensen
11
The Parametric Trap
Sneaks in everywhere!
Henrik Bærbak Christensen
12
Parametric design
Henrik Bærbak Christensen
13
Remedies
It is a well known liability of the Strategy pattern
that it may need to expose methods that are only
relevant for some of its algorithm
implementations…
Benefits
• Avoid bloats of switches
Liability
• Less cohesion in Strategy
Henrik Bærbak Christensen
14
And …
The Heuristics
Set or Boolean?
Coverage and preconditions
Four identificerede invalide ECs:
r < 0; [1], r > 15 [2] c < 0; [4], c > 15 [5]
– Fine to document them as ECs! But test cases ???
Henrik Bærbak Christensen
16
Decorator
How to ‘decorate and undecorate’?
Name problems with this solution?
Name a proper solution...
Henrik Bærbak Christensen
17
Non-Decorator
Decorator adds behaviour – it does not
invalidate it!
Henrik Bærbak Christensen
18
Next: About GUI for HotCiv
Remember the virtues of TDD!
Keep focus, take small steps
– Download the NEW zip, unzip, and run the targets
• = green bar 
– Move one test class from your hotciv into folder struct.
• Loop until compile ok { move missing class into this struct }
Henrik Bærbak Christensen
19