<< February 24, 2004 | Home | February 26, 2004 >>

I'm Going To Reuse It

Lately I've been thinking about why it is that programming is so hard. I'm convinced that programming is hard because we make it hard ourselves.

How do we make programming hard? Easy, just follow some "in fashion" advice blindly without thinking. Here's some examples:

  • I'm going to reuse it. I hear this phrase uttered too often while a programmer is working on a specific problem. The desire to make the solution general also makes the solution complicated. Without the actual "here and now" reuse to test for the "general" solution at another spot leaves the solution not general enough, making it unusable when the time comes. At the end, a lot more complexity without any pay off.
  • I'm about to write a new class. I'll write an interface for it. The use of interfaces at strategic places when different subsystems interact with each other is a good thing. Over use it, at a level where things should be tightly couple, you are inviting more work. Not only can't you navigate from the call site to the definition within an IDE, you are also required to modify two places every time your class changes.
  • I'll just call super. In rare situations when you are using a class library not of your own making, and when you painted yourself into a corner, override a method and then calling super can be used as a last resort. In all other cases, you are better off not do it.
  • I'll just create a thread. I don't need to synchronize anything. No, you won't! As soon as you create that thread, the need to synchronize will be apparent to you. And nine times out of ten, you wish you have not used threads.
  • This class should be a singleton. Really? Have you read about the guarantees provided by your favorite language for static initialization?
  • This is just an Abel-Galois permutation convolution isomorphism. I'll just use the Hamilton-Vick-Sylvester algorithm here. Say good-bye to maintainability of your code by anybody else but you.

Don't know about the Hamilton-Vick-Sylvester algorithm? And you call yourself an Architect?