Skip to content

Instantly share code, notes, and snippets.

Last active Feb 13, 2019
What would you like to do?
Baseline of software engineering 101.

Programming is the art of telling another human what one wants the computer to do. — Donald Knuth

As Robert C. Martin stated in his book Clean Code: A Handbook of Agile Software Craftsmanship,

“Clean code is code that has been taken care of. Someone has taken the time to keep it simple and orderly. They have paid appropriate attention to details. They have cared.”

Why should you care? What’s wrong with code that just works?

Because software is never written once and finished. It needs to be enhanced, fixed, maintained, usually by more than one person.

If code is not clean, let's call that bad-code, changes are not only more difficult, each successive change will become more difficult. From the point of view of business, that means your code becomes increasingly costly to maintain, and approaches a state where that becomes practically impossible.

Imagine your key business functions rely on software... Your competitors deliver products and customer experiences. While your software reaches a state of deterioration such that it cannot be enhanced quickly or cost effectively. It doesn't take a software engineer to know this isn't a situation you want your business to be in! However that's effectively what stops business from competing effectively in the 21st century market.

There's wide range of opinion about what constitutes clean code, so we'll attempt a simplistic definition...

Clean Code Defined.

  • It can be read, understood, and enhanced by a developer other than its original author†.
  • It has automated unit and acceptance tests.
    • (simply put, you and your team can be confident it does what was specified, and keeps working when changed!)
  • It has meaningful names.
  • It is composed of coherent modules.
  • It provides one way rather than many ways for doing one thing.
  • It has minimal dependencies (which are explicitly defined)
  • It has dependencies which can be replaced or changed easily.
  • It provides a clear and minimal external interface (i.e. API)

(† ideally in a few hours!)

UI Clean Code.

Clean UI should be composed of declarative components whicb are bound to presentation logic and/or business logic APIs via a thin layer.

  • Layout, Styling and Interaction logic (animation etc.) should be separated and abstracted from each other, in some reasonable way.
  • Business and presentation logic domains are separate, they each adhere to clean code definition above.

On Dependencies ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment