I was writing some code today and got to pondering, as one does when writing code.
There are many ways to organize code. There’s the camp that wants to cram as much logic into the least space. There are the folks that, for reasons known only to themselves, want to make things as complicated and verbose as possible. (My theory on the latter camp is they are fresh from school; complexity tends to be rewarded there from what I have seen.)
What was I doing?
I read a book on Ruby last week… the author was going over some of his tenets.
The one thing that really stuck, and this was more from how it was phrased, was the idea of coding for maximum obviousness.
That concept just resonated with me. I’ve said it in other ways before — previously I would say that code wasn’t meant for compilers, but for humans. That compilers can handle all sorts of drek, but humans have a hard time if things aren’t written well.
Humans need obvious. Of course “obvious” is subjective, but obvious tends to just be “as simple as possible, but no simpler.” It’s all about coming up with the correct abstraction so the code just gets out of the way of the ideas.
That, in a nutshell, is my feeling.
The code should be obvious and just get out of the way.
Anything less is something to question.