If everyone does it incorrectly, then don’t do it

It seems that Bruce Tate is falling for the “if people do it incorrectly then it should be avoided” argument. Mike Clark was using the same argument with respect to comments: “how many times have you been bitten by inconsistent or wrong comments?”. (I should mention that Mr. Clark didn’t advocate dropping comments completely — only that they be used when the code isn’t clear enough.)

Like Mr. Tate, I too have reviewed much code. There are two mistakes that are quite common in the code I have seen:

  • The effects of multiple threads on code are not well understood. Specifically, synchronized is sprinkled apparently randomly over the code.
  • Inheritance is used as a code-reuse mechanism rather than an is-a relationship.

Following Mr. Tate’s and Mr. Clark’s logic, we should eliminate inheritance and synchronized (and probably even threads!).

As I’ve said before, to me this is all a training issue. I honestly don’t expect developers to use exceptions, comments, inheritance and synchronized correctly since they’re never trained to do so. Most “figure it out” (coding or “software engineering” that is) as they go along. There are a number of books out there with the necessary information, but unfortunately, there are no “problems to solve at the end of the chapter”. Until we address this training issue, I’m afraid that most developers will continue to incorrectly use these constructs.

Advertisements

One comment

  1. Pingback: More on Code Comments « rgrzywinski


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s