Software Design: Tidy First?

Share this post

User's avatar
Software Design: Tidy First?
Tidying: Move Declaration & Initialization Together

Tidying: Move Declaration & Initialization Together

Kent Beck's avatar
Kent Beck
Jun 15, 2022
∙ Paid
14

Share this post

User's avatar
Software Design: Tidy First?
Tidying: Move Declaration & Initialization Together
7
Share

[I’m so so excited. I thought for sure I was done with the catalog of tidyings. Then I ran across this one. Gives me hope that I’ll find even more tidyings out there. Send in your favorites! —kb]

Variables & their initialization seem to drift apart sometimes. The name of a variable gives you a hint as to its role in the computation. However the initialization reinforces the message of the name. When you come across code that separates the two, declaration (with a possible type) & initialization, & the code is harder to read. By the time you get to the initilization, you've forgotten some of the context of what the variable is _for_.

Here's what this tidying looks like.

This post is for paid subscribers

Already a paid subscriber? Sign in
© 2025 Kent Beck
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share