Editor's Note: I found this in my drafts, dated 2012-01-25. I have opted to retain the content unchanged, merely updating links for ubiquitous HTTPS and replacing broken links as needed. Please enjoy this work of fiction.
The President saw that things took time to implement in code, and involved programmers, testers, and a deployment. As someone who liked to make snap decisions and have the results available immediately, this did not sit well in his heart. Long he meditated, then announced his solution:
Henceforth, the system would be Database-Driven.
Showing posts with label flexibility. Show all posts
Showing posts with label flexibility. Show all posts
Sunday, May 17, 2026
Sunday, May 29, 2016
Ten Years of Inheritance (in professional coding)
I wrote in another draft:
I wanted to write about that a little more.
Cases where inheritance has worked out well: when I can arrange for a base class to provide a lot of functionality, and one or maybe two abstract methods overridden in the subclass. Essentially, this comes down to “using inheritance as a mechanism to implement a strategy for some small, but critical, polymorphic bit.” Or perhaps, “making a DSL by providing operations in a base class, then implementations in child classes.”
Probably the most accessible example of this is PHP’s FilterIterator which does little more than wrap a regular Iterator with an
Notably, it doesn’t extend anything itself to do this. It composes another iterator and exposes that through the OuterIterator interface.
And fundamentally, inheritance is the wrong tool for reuse. Providing lots of small methods to make for improved reuse through inheritance is an equally wrong approach.
I wanted to write about that a little more.
Cases where inheritance has worked out well: when I can arrange for a base class to provide a lot of functionality, and one or maybe two abstract methods overridden in the subclass. Essentially, this comes down to “using inheritance as a mechanism to implement a strategy for some small, but critical, polymorphic bit.” Or perhaps, “making a DSL by providing operations in a base class, then implementations in child classes.”
Probably the most accessible example of this is PHP’s FilterIterator which does little more than wrap a regular Iterator with an
accept() method.Notably, it doesn’t extend anything itself to do this. It composes another iterator and exposes that through the OuterIterator interface.
Sunday, August 15, 2010
Perfectly Flexible
Sometimes, a stakeholder doesn't like the idea of requiring a Programmer to make lengthy changes to a project's code if the requirements were to change at some future date. The proposed solution is always simple: The System just needs to be more flexible.
Having been the unsuspecting Programmer on a couple of these projects, I can report that the simple solution does not work.
Having been the unsuspecting Programmer on a couple of these projects, I can report that the simple solution does not work.
Subscribe to:
Posts (Atom)