Simple Code

Post on 14-Jun-2015

415 views 2 download

Tags:

description

Why Simple Code matters ? Simplicity is the key for delivering the right software that matter

Transcript of Simple Code

Simple Code- The Simple Life in Software Land -

1Rui Carvalho @rhwy :: rui.fr

2

I’m Agile, Should I care?

3

Agile Cats

4

follow XP rules

Agile Cats

5

Complexity is Everywhere

6

Complexity is Everywhere

and making things simple is hard!

7

The Domain Complexity

Customer needs ‘Foo’

8

…You think schema ‘Bar’

9

Wrong models cause massive accidental complexity

Greg Young10

11

Solving the wrong problem

12

« It should go faster ! »

13

Change the Engine, problem solved!

14

Hidden Technical Complexity

15

Frameworks?

16

17

18

How big ?

19

Config > Domain

A framework …

= calls you20

21

You

Call

the Library

all that matters!

Bad Understanding Poor design No design

Technology locking

22

} Generates Complexity !

23

Technical debt is watching you!

24

25

Start simplicity now before it blows you!

26

How to start ?

27

Remember Agile Principles?

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.

28Kent Beck

the 4 elements of Simple design

• Passes its tests• Minimizes duplication• Maximizes clarity• Has fewer elements

29

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

31

Simple Design Dynamo

(c) jbrains 2013

32

What else ?

Better Naming

Iterate & refactor 33

Remove Duplication

What problem are trying to solve?

Always!34

Avoid coupling

everywhere, from classes to libraries

35

Be Consistent

Readability, Rules, Conventions36

Be functional!

Be declarative, Immutable, use lambdas

37

Practice !

Practice, Practice, Practice ! …

38

Get more Fun

39

All you need…http://c2.com/cgi/wiki?

ExtremeProgrammingRoadmap

40

http://blog.thecodewhisperer.com/2013/12/07/putting-an-age-old-battle-to-rest/

Simple Design Dynamo

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

42

Add-on:

lambda refactoring

43The Silence of the Lambas

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

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

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 );

47

Add-on:

More quotes

There is no good

but some of them are useful

48

{ Model | Architecture | persistance }

49

“Templates, patterns, frameworks don’t solve anything”

they are just tools to start faster