Shooting fish in the software engineering barrel
I hear, from time to time, comments along the lines of “this code is unclear because it uses objects”. Other common variants include “it’s much better to write everything by hand than reuse functions” and “there’s nothing wrong with a 15-argument function”. When the red mist finally clears from my vision, I tend to come to some sort of argument along the following lines.1
- Possibly.
- But if I follow that argument a few steps further you’re reimplementing the CPU.
- Hope you’re good with a soldering iron.
- Maybe you should think about building your own power station. (Other people’s aren’t to be trusted.)
- I hear Maxwell’s equations aren’t completely accurate; perhaps you should build your power stations using quantum electrodynamics.2
When you’re writing code you’re trying to organize ideas. You aren’t really trying to get a result.3 You’re really trying to work out how to get to a result, and what the result is made up out of. So your 15 argument function is (in some contexts) a couple of arguments that describe one thing, a few more arguments that describe something else, and so on. You’re really trying to work out what the things are.
So if you say: “I’ve got a 15 argument function” you’re saying “something depends on 15 other things and I haven’t been able to find any way of organizing my thoughts on this any better”. When you’re coding you’re trying to organize some domain of knowledge into reusable chunks that someone else can pick up.
The heart of programming is abstraction and design and thinking about the domain. Typing hieroglyphics into a computer is just a way to realize the vision in your head, in much the same way that carpentry is a bit more than hacking at a length of 2x4 with a chainsaw.