I use a library which I need to patch. I need to fork it because Factory design patter is not used.
Library has that structure: class X that hold references to other classes, that hold references to other classes and few more layers. Class hierarchy is “tree-like” structure.
I look for best way for refactoring – flexible enough to prevent people forking it. I cannot find any best practices on that problem.
Over years I use to solve it by “Injecting Factory” – Factory pattern where parent object is being injected (DI) in factory method. I cannot find any documentation on such approach and I need some feedback on it (e.g. theory or possible problems).
I describe it with an example with Car: