Big reusable things are complex

Big reusable things are complex

Conditionals tend to gather mass and live inside “reusable” components.

Rich Hickey says that conditionals complect the "why" with the rest of the program.

Big reusable things are complex. They pull in concerns from various places into a single place, and then twist them all together such that they must all be considered together.

Think about the gnarliest parts of a codebase you work on. When you encounter a conditional, and you need to make a change, are you going to refactor the conditional out? Absolutely not. You’re going to add another condition. This conditional is going to grow and grow until its mass attracts bugs the size of the bug from Men in Black. Where does this conditional live? Is it well named, or is it named so generically such as to be opaque and unhelpful?

Imagine, instead, more, smaller objects. They aren’t each reusable - they each do one thing. They are much more aptly named, which aids readability. It’s okay to add another one, because they aren’t all twisted together. They’re neat and organized.

Rather than building a single, large, reusable thing, build smaller objects and consider something like the abstract factory pattern.

Subscribe to The Daily Developer for more articles like this.

要查看或添加评论,请登录

Dave Paola的更多文章

  • How I hire great engineers

    How I hire great engineers

    Originally published on The Daily Developer. Check it for programming and engineering leadership wisdom.

  • Embracing the Journey from 'Stuck' to 'Aha!' Moments

    Embracing the Journey from 'Stuck' to 'Aha!' Moments

    During a recent "Open Mic" with The Agency of Learning's members, a powerful truth emerged: the journey of a developer…

    2 条评论
  • Jellyswitch January Update

    Jellyswitch January Update

    This morning we're announcing some cool stuff for our customers. Would like to talk more about why! Our goal is to…

社区洞察

其他会员也浏览了