On expressing intent

In programming, one of the hallmarks of well-written code is the fact the code communicates intent. For example, a piece of code could be taking a list of integers, summing them up and dividing the sum by the number of integers involved, but it makes it far easier when the piece of code is actually labelled getAverageValue.

That is intent.

Being able to communicate intent when coding is especially important when working in the context of a development team. Chances are, somewhere down the track, another programmer will need to interact with, or make changes to code that you’ve written. When that time comes, one of the first questions he/she’ll be asking is “what was the author trying to do?”.

getAverageValue
Success!

“Loop over a list, sum up all the elements in the list, count the number of elements in the list, divide the sum by the count”
Fail.

Coming clean with intent isn’t always easy though. In the limited example above, explicitly stating that one’s intention to derive an average value quickly opens oneself up to criticisms on technique, algorithms used, coding style, etc. So vulnerable is such a position that one would often prefer NOT to state intent, opting instead to just step through the instructions one at a time.

But here’s the nice thing about communicating intent – it opens up a space for individuals to share and collaborate over a piece of work.

You see, to put forward intent is a posture of respect toward the other party. It is an invitation to collectively deliberate over a matter. Correspondingly, to ask “why” is a request to participate in one such engagement.

For example, instead of just saying

“Please do this because I told you so”

one might instead say

“Please do this so that the world will not come to an end”.

No prizes for imagining the effect the former statement might have on a conversation. The latter, on the other hand, opens up far more opportunities for discussion, i.e. –

“I don’t want the world to end either, but here’s possibly a better way to achieve it”

or

“I don’t think the world will end. Let’s talk about why you think the world will end.”

Lots of room to parley and a far better chance of arriving at a progressive and agreeable outcome.