Skip to content

Design code toward library quality

Better code is correct, efficient, and reusable. As an industry we produce so much code that is a one-off. It is such a waste of time and talent. I try to encourage every developer to write all code as if it were going to be part of a library, ideally part of the standard, and to use library components. - Sean Parent on https://www.meetingcpp.com

This might seem extreme - why design throwaway application code like a reusable library?

Even if your code will never become a reusable library, this mindset forces better design decisions.

It’s about the design discipline that library thinking enforces:

  • Clear boundaries between concerns - Each component has a well-defined responsibility
  • Intuitive, easy-to-use interfaces - See Do not confuse abstraction with obfuscation
  • Separation of concerns and loose coupling - Components don’t depend on irrelevant details
  • Building good design habits - Consistent practice of quality principles

The value isn’t potential reuse - it’s that library-quality thinking prevents design shortcuts that create maintenance headaches later.

When your code feels like it could be extracted into a reusable library, you’re probably following good design principles. The mindset serves as both motivation and validation for quality practices.