Reveal intent, hide implementation

Coding Unicorn πŸ¦„ on May 19, 2020

When writing code, it's important to distinguish between INTENT (what is happening) and IMPLEMENTATION (how things work). ❌ In the example below, ... [Read Full]
markdown guide

Just so right. Everything we make is effectively a series of Russian dolls, seeing the fraught intricate detail of an inner implementation adds massively to cognitive load.

It's a style thing though - I think a lot of people just want to start coding as they think - if you can get in the habit of WRITING the way you suggest, it becomes second nature. You write the filter and just put a name in there that does what you want, then you write the function.

I'm "ok" at this. Looking at my code right now I can see I've done this a lot for complex functions but I guess I'm inconsistent on what level of complexity...

const localFields = useFields(target.document)
        .filter((f) => f.name)

Yay, useFields isn't listed out in full detail - but hmm - what is that intention about f.name...

const localFields = useFields(target.document)

Much better... I'm off for some refactoring


Perfectly explained. πŸ‘πŸ‘

Code that tells a story is maintainable, declarative, intention-revealing code (what?, not how?) comes first and is used to hide the implementation (how?), hide the information that may be irrelevant to the one reading your code, or label it in case it IS relevant: Here you have to look.

It is one of the principle guidelines that seem easy to follow but are actually very hard to out into practice every day, for you can easily slip into bad habits. We all have been there, and we owe it to the ones coming after us to pass this on.

Thanks for your contribution!


this reminds me of a phrase I heard once, "friends don't let friends play compiler."


I know this is off topic, but what's the story with that dress, it's ace, I want a hoodie like this!

code of conduct - report abuse