lundi 16 mai 2016

Inheriting or Composing a Design Pattern

I am not a team lead, but I'm trying to help push my team's code in the correct direction. A lot of our code fails to use design patterns, and I see this as a major flaw. It becomes hard to maintain and update, hard to explain, and a beast to relearn. I'm asking for help on here, because I don't want the usual answer of "just get it done and worry it about it later".

I'm attempting to create most of the Design Patterns from GoF in Javascript. I have the choice of either using composition or inheritance. My gut feeling is to use inheritance because it will supply all the logic for future systems, and we just have to extend whichever Design Pattern we need. Less chance of a "boo boo". However, I have heard time and time again that it is better to use composition. I feel like composition would just be redundant because all we would be doing is writing wrapper code to call the Design Pattern Object's method.

Am I attempting to overuse inheritance, or is this an acceptable case?

Aucun commentaire:

Enregistrer un commentaire