I have a set of classes that work together (I code in javascript).
There is one parent class and several child classes that are created by the parent class. I have several clients of these classes, each of which must add one or more methods to the parent or child classes.
Instead of every client inheriting from these classes, which is doable, but randomly due to child classes, I have these clients passing functions to the parent class when they instantiate the main class.
The main class dynamically creates methods, and clients can call methods similar to the ones they were there all the time.
My questions:
- Is this a reasonable thing?
- What will be the design pattern for what I'm doing?
source
share