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

  • View
    1.153

  • Download
    0

  • Category

    Business

Preview:

DESCRIPTION

Presentation at Lean Tribe Gathering 12 in Växjö, 10 dec 2012.

Citation preview

How To Clean Your Dirty CodeAnd Why It Matters

Jonatan Jönsson

2012-12-10

jonatan.jonsson@softhouse.se

Who am I?

Reusable Designs

Reusable Modules

Dirty Versus Clean Code

What does it display?

Red/Green

0

1

Red/Blue Green/Red

Dirty Versus Clean Code

What does it display?

Red/Green

0

1

Red/Blue Green/Red

Naming Is Important

Is This You?

Which Square Fits Your Product?

Total Rewrite Cycle

Iterative Refactoring

Beware of False Sense of Confidence

http://www.eclemma.org

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

http://www.pitest.org

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

Readable Test?

Builder Pattern To the Rescue

Fail Fast - Preferably at Compile-time

Bad: doSomeActionThatRequiresAuthenticatedUser(User authenticatedUser)

Good: doSomeAction(AuthenticatedUser user)

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

Using the Right Data TypeUsing a list Using a set

Using the Right Data Type

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

Packaging By-Layer vs By-Feature

By Layer By Feature

The Ultimate Benchmark of Modularization

What Tools Are You Using?

What Tools Are You Using?

Eclipse Refactoring Support

Peer Review - Pair Programming

Peer Review - Code Reviews

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

(c)lean tribe

jonatan.jonsson@softhouse.se

Recommended Reading

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

Recommended