Hacker News new | ask | show | jobs
by bendavis381 2807 days ago
And don’t use a class if it holds no state.
1 comments

This is not so simple. What about "NullLogSink" and "StdoutLogSink", both being implementations of "ILogSink"?

Classes are very well suited to statically formalize the communication points (aka "interfaces", "protocols") between the various parts of your program.

The fact that a concrete class might have a state is actually irrelevant (indeed, we generally make all of our data members "private").