Wednesday, February 16, 2005

Thought #2 for the day

Some code idioms are inherently bug-prone. High on my list of offenders:

abc()->widget();


abc() presumably returns a pointer to an object that has a widget method. But what if it doesn't have a pointer available?

Programmer: Doctor, it hurts when I do this.
Doctor: So don't do that!


now if abc returned a reference rather than a pointer....

Dale

No comments: