Will the sales team come up with a new discounting idea next month? Will we support new file formats during the lifetime of this product? Are we going to change new data layer to support another database system? These kinds of questions scream for a pluggable design, where part of the source code is loaded based on some configurable option.
Our factories make it possible to create pluggable designs, which mean you can add new functionality to an existing program without changing the existing code. The moment you can ask yourself a question like the ones above, you simply add a Factory and leave the answer for the future.
Developer friendly
An object factory can literally be created with a single line of code. A single attribute tells a class that it should be created by the factory. And you’re done. You can even load DLL’s at runtime or create factories of factories; our factory implementation will automatically eliminate any other code the developer should write. Surely, it won’t get much easier than this.
High performance
Our implementation enables you to easily construct millions of factory objects per second both single-threaded and multi-threaded. A high performance solution for factories means you can make as many things pluggable as you see fit without compromising performance. And because a pluggable design will lead to more flexibility in the future, having the ability to add plugin endpoints everywhere is a very good thing.
Dependency Inversion Principle
The dependency inversion principle tells us tells us that we should try to avoid depending on things that are ‘concrete’. For example, if we should depend on a list structure, but don’t know if we should use a linked list structure or an array structure, we should use the interface that supports both. Our factory uses this principle to build related objects, but goes one step further: objects are constructed based on a key. This means the construction of derived types is also decoupled from the application, which is like a Dependency Inversion Principle on steroids.