28. the 4 XP Simplicity Rules
• Runs all the tests.
• Expresses every idea that
we need to express.
• Says everything Once And
Only Once.
• Has no superfluous parts.
28 Kent Beck
29. the 4 elements of Simple design
• Passes its tests
• Minimizes duplication
• Maximizes clarity
• Has fewer elements
29
30. 2 final rules
Developing strong skills of detecting
duplication, removing duplication,
identifying naming problems, and fixing
naming problems equates to learning
everything ever written about object-oriented
30
JbRains
40. All you need…
http://c2.com/cgi/wiki?
ExtremeProgrammingRoadmap
40
Simple Design Dynamo
http://blog.thecodewhisperer.com/2013/12/07/
putting-an-age-old-battle-to-rest/
41. Hand written sketches are by me and can be reused under Creative
Commons licence, other images are owned by their authors and I really
would like to thank them if I found all credits …
41
@rhwy
44. 44
interface IPriceCalculator {
double GetPrice(string productReference)
}
class Basket {
IPriceCalculator calculator;
public Basket(IPriceCalculator calculator) {
this.calculator = calculator;
}
public Result AddProduct(
Product product, int quantity) {
Price = calculator.GetPrice(product.Reference);
//other magic here
}
}
45. 45
class UserPriceCalculator : IPriceCalculator
{
public double GetPrice(string productReference)
{ //do some magic stuff here
return price;
}
}
var basket = new Basket(new UserPriceCalculator());
basket.AddProduct(theProduct, 2);
46. 46
class Basket {
public Result AddProduct(
Product product, int quantity,
Func<string,double> calculator) {
Price = calculator(product.Reference);
//other magic
}
}
var basket = new Basket();
basket.AddProduct(theProduct, 2, x=>x.rawPrice*0,85 );