The text of this article is not in this database — only its details are. Read it on the old site: Writing Better Code - Keepin' it Extensible
5 Comments
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment.
The text of this article is not in this database — only its details are. Read it on the old site: Writing Better Code - Keepin' it Extensible
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment.
Tim ClaasonPosted Jan 7, 2011, 11:11 AM
I believe you also bump into the Liskov Substitution Principle by making OpenAnimal abstract (ie not overcommitting to behavior in parent classes).
Sam HobbsPosted Dec 28, 2010, 6:47 PM
I think in the past programmers would say something is "hard-coded" instead of "not open for extension". Is there a significant difference between the two? Also, I certainly agree that it is bad programming to have the same switch statement in multiple places. The critical alternative is to use just one of them in the code and then call that form everywhere it is needed. Of course, things such as maps and dictionaries could help but simply centralizing the code would provide the greatest bang for the buck. This term "Factory Pattern" seems complicated; I get the impression it is more complicated than what is needed in situations such as is presented in this article.
Mahesh ChandPosted Dec 28, 2010, 12:48 AM
Good work.
Mike GoldPosted Feb 21, 2008, 5:00 PM
I also find that I need a way to decide which object to construct once I've refactored from the switch statement. Rather than create a switch for deciding on construction, I suppose a Factory pattern is good for this?