Top Banner
How To Clean Your Dirty Code And Why It Matters Jonatan Jönsson 2012-12-10 [email protected] e
29

How to clean your dirty code | Jonatan Jönsson | LTG-12

May 06, 2015

Download

Business

Lean Tribe

Presentation at Lean Tribe Gathering 12 in Växjö, 10 dec 2012.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: How to clean your dirty code | Jonatan Jönsson | LTG-12

How To Clean Your Dirty CodeAnd Why It Matters

Jonatan Jönsson

2012-12-10

[email protected]

Page 2: How to clean your dirty code | Jonatan Jönsson | LTG-12

Who am I?

Page 3: How to clean your dirty code | Jonatan Jönsson | LTG-12

Reusable Designs

Page 4: How to clean your dirty code | Jonatan Jönsson | LTG-12

Reusable Modules

Page 5: How to clean your dirty code | Jonatan Jönsson | LTG-12

Dirty Versus Clean Code

What does it display?

Red/Green

0

1

Red/Blue Green/Red

Page 6: How to clean your dirty code | Jonatan Jönsson | LTG-12

Dirty Versus Clean Code

What does it display?

Red/Green

0

1

Red/Blue Green/Red

Page 7: How to clean your dirty code | Jonatan Jönsson | LTG-12

Naming Is Important

Page 8: How to clean your dirty code | Jonatan Jönsson | LTG-12

Is This You?

Page 9: How to clean your dirty code | Jonatan Jönsson | LTG-12

Which Square Fits Your Product?

Page 10: How to clean your dirty code | Jonatan Jönsson | LTG-12

Total Rewrite Cycle

Page 11: How to clean your dirty code | Jonatan Jönsson | LTG-12

Iterative Refactoring

Page 12: How to clean your dirty code | Jonatan Jönsson | LTG-12

Beware of False Sense of Confidence

http://www.eclemma.org

Page 13: How to clean your dirty code | Jonatan Jönsson | LTG-12

If It’s Not Tested, Assume It’s Broken

http://www.pitest.org

Page 14: How to clean your dirty code | Jonatan Jönsson | LTG-12

See Every Part of Your Code As an API

• Easy to use right, hard (preferably impossible) to misuse

• Easy to evolve

• The cleanliness of your tests reflects the quality of your API

• Be as small as possible, ”when in doubt leave it out”, Joshua Bloch

Page 15: How to clean your dirty code | Jonatan Jönsson | LTG-12

Readable Test?

Page 16: How to clean your dirty code | Jonatan Jönsson | LTG-12

Builder Pattern To the Rescue

Page 17: How to clean your dirty code | Jonatan Jönsson | LTG-12

Fail Fast - Preferably at Compile-time

Bad: doSomeActionThatRequiresAuthenticatedUser(User authenticatedUser)

Good: doSomeAction(AuthenticatedUser user)

Page 18: How to clean your dirty code | Jonatan Jönsson | LTG-12

Don’t Make the Client Do Anything the Module Could Do

Page 19: How to clean your dirty code | Jonatan Jönsson | LTG-12

Using the Right Data TypeUsing a list Using a set

Page 20: How to clean your dirty code | Jonatan Jönsson | LTG-12

Using the Right Data Type

http://code.google.com/p/caliper/

Page 21: How to clean your dirty code | Jonatan Jönsson | LTG-12

Packaging By-Layer vs By-Feature

By Layer By Feature

Page 22: How to clean your dirty code | Jonatan Jönsson | LTG-12

The Ultimate Benchmark of Modularization

Page 23: How to clean your dirty code | Jonatan Jönsson | LTG-12

What Tools Are You Using?

Page 24: How to clean your dirty code | Jonatan Jönsson | LTG-12

What Tools Are You Using?

Eclipse Refactoring Support

Page 25: How to clean your dirty code | Jonatan Jönsson | LTG-12

Peer Review - Pair Programming

Page 26: How to clean your dirty code | Jonatan Jönsson | LTG-12

Peer Review - Code Reviews

http://code.google.com/p/gerrit/

Page 27: How to clean your dirty code | Jonatan Jönsson | LTG-12

(c)lean tribe

[email protected]

Page 28: How to clean your dirty code | Jonatan Jönsson | LTG-12

Recommended Reading

Page 29: How to clean your dirty code | Jonatan Jönsson | LTG-12

Referenceshttp://www.osnews.com/story/19266/WTFs_m - WTFs per minute cartoon

http://jester.sourceforge.net/ - Test coverage tool

http://en.wikipedia.org/wiki/Mutation_testing

How To Design A Good API and Why it Matters - Joshua Bloch