Wrapped Prototype simply declares the function in the global scope, and everything else, including its
prototype, inside an
immediately-invoked function expression.
This pattern can be desirable when:
1. You don't need/want private/protected instance variables.
2. You don't need/want protected function.
3. You don't mind having duplicated private static constants.
4. You need/want extremely performant object creation codes that scale very well.
5. You need/want/don't mind every subclass to choose its direct parent but not vice versa.
Composable Revealing Module simply wraps everything into a named function that's called rather than instantiated.
This pattern can be desirable when:
1. You don't need/want protected function/variables.
2. You don't mind having duplicated private functions/variables.
3. You don't need/want to extend the objects at all or you don't mind suffering from poor scalability.
4. You need/want extremely fast object creation codes, even at the cost of high memory usage, and you don't need/want to extend the objects at all.
5. You need/want private functions/variables.
6. You favor
composition over inheritance.
Parasitic Inheritance simply wraps everything into a named function that's called by subclasses and instantiated to create new objects.
This pattern can be desirable when:
1. You need/want private and protected functions/variables.
2. You don't mind having duplicated private constants.
3. You don't mind extremely unperformant object creation codes that doesn't scale well.
4. You need/want/don't mind every subclass to choose its direct parent but not vice versa.
5. You don't mind having protected functions/variables compromised, which can compromise the integrity of the whole object as well.
6. You need/want multiple inheritance.
7. You need/want/don't mind subclasses turning the protected functions/variables into public ones.
Reversed Inheritance Hierarchy simply wraps everything into a named function, including the declaration of all subclasses, that's instantiated to create new objects.
This pattern can be desirable when:
1. You need/want private and protected functions/variables.
2. You don't mind having duplicated private constants.
3. You don't mind having excessively unperformant object creation codes that lacks scalability.
4. You need/want/don't mind having every parent to choose all its subclasses but not vice versa.
5. You don't mind leading to effectively final classes when no one has access to their source codes anymore.
6. You don't mind managing an unmaintainable mess with a colossal, complex and convoluted inheritance hierarchy.
Reversed Prototype Chain simply wraps everything into a named function, including the declaration of all subclasses and defintion of the prototype for creating objects, that's called once to return a function creating objects.
This pattern can be desirable when:
1. You need/want protected functions/variables.
2. You don't need/want private instance variables.
3. You don't mind having duplicated private constants.
4. You don't mind having slightly unperformant object creation codes that's decently scalable.
5. You need/want/don't mind having every parent to choose all its subclasses but not vice versa.
6. You don't mind leading to effectively final classes when no one has access to their source codes anymore.
7. You don't mind managing an unmaintainable mess with a colossal, complex and convoluted inheritance hierarchy.