Everyone should write code for some one else. The back and forth of hammering out interfaces is just a part of it. The real learning comes from the other person doing things you never thought they would. When the complaints and bugs come back you get the chance to figure out where you went wrong.
Here are my favorites from C++ Win32 programming:
- Misusing or not using an interface because they "didn't understand it"? "Then why didn't you ask", you mutter.
- Passing the wrong parameters, but somehow it "just works but I don't know how", they quip.
- Threading/Concurrency. This is the biggy. You probably never expected that object to be used on a different thread did you? Whose job was it to make this object safe, yours or mine?
- Blocking, a corollary to the above. Your method call blocks, but the caller doesn't want it to. They almost never do.
Your code becomes more useful because it is easier to use. It solves more people’s problems and they look forward to using it.
In the end you become a better programmer. You find even the interface that you create just for you are more useful. "Cool, I can use that same widget X in program Y without any changes." That is when you know you have got it right.
So, all I am asking is spend 5 minutes during the design and think, "How could someone else abuse this?" It will make for a better design. Besides, who knows, you might be the one that wants to "abuse" the interface later on. Let's make sure you don't have to.
No comments:
Post a Comment