Skip to main content
The Bike Shed

455: Noisy Animals Kata with Fritz Meissner

46 min episode · 2 min read
·
Fritz Meissner

Episode

46 min

Read time

2 min

Topics

Health & Wellness, Design & UX, Software Development

AI-Generated Summary

Key Takeaways

  • Separating branching from doing: Write methods where conditionals only dispatch to other methods without logic inside branches. This separation helps identify natural algorithm joints, enables easier subclassing, and supports the open-closed principle by creating stable override points for future extensions.
  • Flocking rules for refactoring: When two code sections appear different, make small changes to unify one aspect first, creating duplication you can then eliminate. This technique from 99 Bottles of OOP enables safe, incremental refactoring without requiring large risky rewrites or complete upfront understanding.
  • Commit at every refactoring step: Create git commits after each small change like inlining a method or replacing a conditional, with descriptive messages explaining your thinking. This practice enables easy rollback, preserves decision history for reviewers, and forces reflection that often reveals whether changes actually improve code.
  • Cardinality analysis for conditionals: Analyze nested conditionals by counting unique combinations of parameters rather than branch depth. A problem with two binary parameters has cardinality of four, suggesting a flat four-branch structure may be clearer than nested conditionals, enabling theoretical proof of correctness before implementation.

What It Covers

Fritz Meissner presents his Noisy Animals Kata, a code refactoring exercise designed to teach developers how to clean up messy conditional logic through incremental steps, reflection questions, and multiple solution approaches without requiring prior refactoring knowledge.

Key Questions Answered

  • Separating branching from doing: Write methods where conditionals only dispatch to other methods without logic inside branches. This separation helps identify natural algorithm joints, enables easier subclassing, and supports the open-closed principle by creating stable override points for future extensions.
  • Flocking rules for refactoring: When two code sections appear different, make small changes to unify one aspect first, creating duplication you can then eliminate. This technique from 99 Bottles of OOP enables safe, incremental refactoring without requiring large risky rewrites or complete upfront understanding.
  • Commit at every refactoring step: Create git commits after each small change like inlining a method or replacing a conditional, with descriptive messages explaining your thinking. This practice enables easy rollback, preserves decision history for reviewers, and forces reflection that often reveals whether changes actually improve code.
  • Cardinality analysis for conditionals: Analyze nested conditionals by counting unique combinations of parameters rather than branch depth. A problem with two binary parameters has cardinality of four, suggesting a flat four-branch structure may be clearer than nested conditionals, enabling theoretical proof of correctness before implementation.

Notable Moment

Fritz challenges the common developer heuristic that shorter code equals better code, explaining that while this serves junior developers well by reducing complexity, intermediate developers must recognize shortness as merely a proxy for readability rather than an optimization goal itself.

Know someone who'd find this useful?

Episode Transcript

Hello, and welcome to another episode of The Bike Shed, a weekly podcast from your friends at Thoughtbot about developing great software. I'm Joelle Kenville. And today, I'm joined by fellow Thoughtbotter, Fritz Meissner. Hello. And together, we're here to share a bit of what we've learned along the way. So, Fritz, what's new in your world? Well, I am looking at optimizing a Postgres query. I have a query that runs a lot of the time. It's fairly fast, but it needs to be faster. What I can see is that it's not using the index that I think it should. I can see the index is there, so now I'm trying to create a new index that Postgres will understand. That's interesting. How can you tell that it's not using the index? With an explain plan. So if you say, explain, analyze in, side of your Postgres, client, it'll spit back some information about what the query is actually doing, like, what it's doing to retrieve data. And I can see that it is using an index, just not the one I wanted to use. Do you think the query planner is correct in thinking that not using this index is the fastest way to work? Or do you think this is the case where you as a developer, like, no. It would be faster if you use this index. Please use this index and don't do what you actually are hoping to do. Yeah. I'm I'm pretty sure that it's wrong and I'm right. But the only way to really know is to, try. So we'll create the index and then see what happens afterwards. It is no great loss if it doesn't fix the problem or at least it'll be I'll be sad that it isn't solved, but we'll try something else. How often do you run into situations where you think the database query planner is wrong and you're right? This is probably the first time in my career that I've thought that. Okay. Yeah. So I feel like I always tend to blame myself in those situations. I'm like, well, if the query plan is choosing to not use my index, clearly, I am indexing on the wrong thing here, or the dataset is too small or something like that. I need to refine my approach. Yeah. I guess it is pretty bold to assume that all of the knowledge that's baked into Postgres is, wrong, and my grasp of it is better. What's new in your world? Oh, I've been recently fighting with some tricky unit tests. Yeah. This is an RSpec test, and I'm parsing data from a third party API that comes in as JSON, and it gets turned into a pretty complex series of nested active model objects. Yeah. And my assertion on this parser is that it will return I give it some JSON. I parse it, and then I expect the response to have certain attributes, using our …

Get the full transcript (7,428 words) + summary by email — free

One-time email with the complete transcript and AI summary of this episode. No account needed.

One email, no spam. We’ll also show you what SignalCast does.

Browse all The Bike Shed transcripts →

You just read a 3-minute summary of a 43-minute episode.

Get The Bike Shed summarized like this every Monday — plus up to 2 more podcasts, free.

Pick Your Podcasts — Free

Keep Reading

Books, tools, and gear mentioned in this episode

SignalCast may earn commission on purchases via these links. As an Amazon Associate, SignalCast earns from qualifying purchases.

Books

More from The Bike Shed

We summarize every new episode. Want them in your inbox?

Similar Episodes

Related episodes from other podcasts

Explore Related Topics

This podcast is featured in Best Cybersecurity Podcasts (2026) — ranked and reviewed with AI summaries.

Read this week's Health & Longevity Podcast Insights — cross-podcast analysis updated weekly.

You're clearly into The Bike Shed.

Every Monday, we deliver AI summaries of the latest episodes from The Bike Shed and 192+ other podcasts. Free for one show.

Start My Monday Digest

No credit card · Unsubscribe anytime