Skip to Content
Tidy First?
book

Tidy First?

by Kent Beck
October 2023
Intermediate to advanced
122 pages
1h 58m
English
O'Reilly Media, Inc.
Book available
Content preview from Tidy First?

Chapter 17. Chaining

Tidyings are like potato chips. You eat one, and you’ll want another. Managing the urge to keep tidying is a key tidying skill. You just tidied; should you tidy more? It depends (we’ll get to what it depends on in Part III).

How big you step will be up to you, but I encourage you to experiment with sticking to tiny tidying steps. Optimize each step. From the outside it will look like you are running, but, like the centipede, you will know you’re taking many little steps.

Tidying becomes a game of chess, with moves visible ahead. Let’s look at how tidyings set up further tidyings:

Guard clause

Once you’ve set up a guard clause, the condition may benefit from being turned into an explaining helper or extracted into an explaining variable.

Dead code

Once you’ve removed the clutter of dead code, you may be able to see how to sort the code into reading order or cohesion order.

Normalize symmetries

Once you’ve made identical code identical and different code different, you may be able to group precisely parallel code into reading order. I did this once with a file containing several web entry points. Once they all looked alike, it was natural to group them at the top of the file as a kind of table of contents to the rest of the code.

New interface, old implementation

Once you have your shiny new interface, you’ll want to use it. If you don’t have the automated rewrite tools to convert all callers, you’ll need to convert them one at a time. This is the first ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Building Micro-Frontends

Building Micro-Frontends

Luca Mezzalira
Learning Go

Learning Go

Jon Bodner
Head First Git

Head First Git

Raju Gandhi

Publisher Resources

ISBN: 9781098151232Errata Page