Home:ALL Converter>Polymorphism in Design Pattern

Polymorphism in Design Pattern

Ask Time:2010-10-26T00:17:57         Author:Doug

Json Formatter

I have observed that most of the design patterns (I refer mostly from the Gang of Four book) are all based on polymorphism. That leads me to a "enlightened" moment that OOP's polymorphism is the most important feature in the paradigm.

Some of the patterns use polymorphism are: strategy, factory, bridge...

With that, I don't understand why we are not just teaching developers really good polymorphic behavior of OOP instead of overloading them with a bunch of patterns which in fact are based on polymorphism?

Author:Doug,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/4016622/polymorphism-in-design-pattern
Joseph :

Wouldn't\n\n\n really good polymorphic behavior\n\n\nactually be how to apply the Gang of Four patterns in a good way?\n\nAs in, how to apply strategy as a tool so that you don't violate SRP for example.",
2010-10-25T16:19:59
Andrew Arace :

Every language has its features that are the \"killer features\" of the whole concept. OOP, being some of the largest and oldest branch of advanced languages has polymorphism, but I can point out other amazing features such as strong functional programming, closures, parallel execution, and other unique things to other languages that are along the same lines of amazingly-powerful features that are must-haves.\nTeaching just one method quickly turns you into a one-trick-pony. A strong foundation in theory allows you to pick up a very \"different\" language like Lisp or Erlang and know what's going on.",
2010-10-25T16:23:48
Ignacio Vazquez-Abrams :

This is a red herring. Some languages implement this as polymorphism. Others can implement it as interfaces. Still others can use duck-typing. Forcing readers/students into thinking \"polymorphism\" doesn't actually help in all situations without also being taught the other two mechanisms, which don't exist in every language. At that point it becomes noise.",
2010-10-25T16:34:42
David Wolever :

Because, while polymorphism is used to implement the patterns in OO languages, but the patterns can be implemented without it (for example, imagine implementing a factory in C).\n\nAdditionally, design patterns are, like polymorphism, tools that help developers solve problems. Only learning a subset of the tools (eg, only polymorphism) will put developers at a disadvantage because they will need to “work from first principals“ (so to speak) instead of basing their work (and their thought) on higher level concepts (like design patterns).",
2010-10-25T16:24:19
Guy Starbuck :

Well, polymorphism is one of the fundamental concepts of OOP -- it's at a different level of abstraction than the more detailed patterns.\n\nI don't think there is a problem having names for and teaching the more detailed/dependent patterns, it really does help with communication. But as you suggest, a solid understanding of polymorphism is definitely required before a developer would be able to effectively implement any of the dependent patterns.",
2010-10-25T16:24:20
yy