Articulate Coding
casestatement.tumblr.com
casestatement.tumblr.com
Why is this idea true?
Do I really believe it?
Could I convince someone else that it is true?
Why didn't the author use a different argument?
Do I have a better argument or method of explaining the idea?
Why didn't the author explain it the way that I understand it?
Is my way wrong?
Do I really get the idea?
Am I missing some subtlety?
Did this author miss a subtlety?
If I can't understand the point, perhaps I can understand a similar but simpler idea?
Which simpler idea?
Is it really necessary to understand this idea?
Can I accept this point without understanding the details of why it is true?
Will my understanding of the whole story suffer from not understanding why the point is true?
-- How To Read Mathematics, authors Shai Simonson and Fernando Gouvea [1]
[1]http://web.stonehill.edu/compsci/History_Math/math-read.htm#
Have you actually experienced a coder that writes good code but writes it in a manner that prevents you from understanding it? I'd love to see some actual code samples.
What's worse is multiple nested levels of #ifdef. Not only is it hard to tell how the code flows, but you can't even be sure it's all being compiled!
I work with code like this so frequently that I actually got around to learning elisp so that I could write a function in Emacs to highlight the nested levels of #ifdef. I have a black background, so each nested level increases the brightness.
(I should really get around to pulling that code off of my computer at work and putting it up for everyone to use...)
if (.*?) {
vs #ifdef .* ... #else ... #endif
I'd be interested in seeing it, even if it's a pastebin/gist dump that needs some cleanup.I guess Emacs is using some kind of parser to do syntax highlighting, right? I wonder if it's possible to tap into that...
Swapping out those regexen you have wouldn't be too much of a challenge, I don't think, at least for a first shot at it.
I'm more interested in the general structure of managing the counter, applying the various faces to lines, etc.
My email is in profile if you want someone to attempt to clean it up a bit (insofar as I'm capable of doing so) :)
But the exercise shouldn't stop there, as your program develops questions like yours should be asked and understood and defined. The more questions you can ask yourself, the better you'll understand your thought process.
New developers might not get far past my list. Most devs might ask some but not all of your questions. The best developers will realize more fundamental questions to ask about their decisions. Hopefully everyone can learn something new by asking those questions.
However, in a professional environment you would expect that the lead developer(s) had already given this stuff a lot of serious thought and enshrined it in a coding standards document for every member of the team to follow.
Now, you're right, the easiest questions (as in the article) to answer can and should be encoded in standards document. But there are many many questions to ask and some are highly dependent on context and don't belong in standards documents. Maybe some of the existing standards that you thought you understood are really just there by convention and could be improved.
[1] Or do it at merge time if your setup involves pushing to a "work" repo which is merged to the real codebase later.
After years of coding one develops their coding personality that they're happy with and I think their code has just a right mix of carelessness and precision which could be never learned from a script kiddie book.
Point being that most people probably don't get the most out of, say, Python's standard library.
This isn't what I understand to be Analysis Paralysis. AP is when you're trying to analyse the problem and design you're trying to code, and you're overwhelmed by the decisions to make and as a result, unable to proceed.
This, in contrast, is about deliberate reflection on what you're doing so you can better make explicit all the otherwise implicit and internal decisions of which you may otherwise be unaware.
As the article says, coders make hundreds of decisions for every routine they write, most on auto-pilot. Some of those might be less than optimal, and this kind of examination and reflection can help to understand, and possibly improve, those decisions.
[1] Minor edit in the light of subsequent comments.
[2] Hat tip to The Princess Bride
The argument is that these decisions are made, whether you are aware of them or not, and in this case Beck was undertaking to understand them in nit-picking detail so they can be made visible and better understood, rather than remaining implicit, ill-understood, and possibly sub-optimal.
The author wasn't advocating that this sort of thing be done of every line of code - that would be ludicrous in the extreme. Don't attack the extreme strawman, try to understand and appreciate the underlying purpose.
In my 35 years of software work, far, far too often I see people concentrating on the pointless - bike-shedding if you will - and sadly, this is another case. Concentrate on the point that matters - understanding the processes and decisions of coding, and not the details of the specific instance.
The pointless has one great advantage: it is easier to work with. Hard problems are The Unknown, we fear the unknown, and when this fear arises one way to resolve it is by replacing the hard problem with something easier. This is absurd, like the drunk looking for his car keys under the street lamp on the wrong side of the street "because the light's better here", but that doesn't stop us, it just means we do it unconsciously. Now we have a simpler problem that we can concentrate on and (best of all) argue about.
You see this in obvious places like curly brace wars, but there are more interesting examples, such as why editors and version control systems get so much attention. They're important, but not that important. But they're easy to understand and have an opinion about. Better still, they're common across many projects so arguing about them is a way for programmers to socialize.
Perhaps the same pattern is behind our industry's tendency to embrace savior paradigms (Structured Programming, OO, Agile, FP).