01.29.09
Occam’s Razor
While most people quote Occam’s Razor as “the simplest thing is most likely correct,” the actual quote is “do not multiply entities needlessly.”
I’m not sure that this is good programming advice. I do, however, think it’s an accurate description of how most developers behave. Typically, a developer will create as few discrete entities as possible. They will use one class rather than two. They will create a single large interface rather than multiple small interfaces. They will create a single large function rather than break it down into multiple, smaller functions.
It doesn’t seem to be a matter of typing, or of saving characters. The behavior seems to suggest that developers will prefer a single, very large method to two smaller methods, even if the total lines of code is fewer using two smaller methods.
This probably boils down to perceived overhead – creating an ‘x’ may be perceived as managerial type overhead, as opposed to “lines of code” which are real work. If so, it would suggest that the less overhead that’s required to create an entity, the more likely it is that multiple entities will be created.
This is something to keep in mind when designing APIs, user experiences, languages, or other tools that you expect others to use.