Over the years I’ve written quite a few books and many more articles, columns, and blogs on the topic of programming. I think there has always been an idea that if something is in print, it is probably right. But I’ve noticed a recent paradox. Obviously, I can create a website and promote my idea that everyone should learn to whistle modem tones to reduce the barrier to human/machine interfacing. That doesn’t make it a good idea, but simply my opinion (and, just to staunch the flow of incoming e-mail, no, that’s not really my opinion). My point is that in years past things you read were usually subjected to some review and fact checking before it was published. With the Internet, anyone can publish anything (and they do).
The paradox is this: For some reason, it seems to me that people have begun seeking validation at every turn from some authority figure. I first started noticing this when design patterns became popular. Don’t get me wrong, patterns are a useful tool. They help you capture things that work and present them to other people. But real design requires you to evaluate patterns and, if none are suitable, figure out the best answer for your specific problem. So as the quality of published information has probably decreased (taken as a whole), our willingness to assume it is right seems to have increased.
This came to the forefront of my thinking this week when someone waved a 3-year-old article from another magazine at me. It is a fine magazine, and the article – which was talking about how to make better embedded system code – was well written and I agreed with most of what was in it. But there was an admonishment against using “clever” techniques. The author forbids the use of templates, inheritance, goto statements, and the ternary operator (as in x=y>10?1:2). He claimed that only the original programmer will understand such a “clever” solution and then will forget how it works.
I thought this was a stunning example of just what I was talking about. I understand goto isn’t a popular choice, but no templates? No inheritance? The ternary operator is not that hard to understand. Even if I were inclined to agree on all of these, I wonder how many people use an article like this as a reason to forbid the use of these in every situation? I’ve seen it before. Yet, I know that there is almost no rule like this that should be iron clad. Our job as engineers is to find the right solution where “right” is a fuzzy concept based on trading the various things we can change and weighing them against requirements.