Implementing the abstract factory pattern for exchange connectivity
This medium-difficulty C++ design-patterns problem tests whether you can implement the abstract factory pattern—a structural pattern that decouples client code from concrete class hierarchies. In quantitative trading systems, where multiple exchanges with different protocols coexist, this pattern keeps the codebase clean and exchange-agnostic.
The challenge requires you to define concrete factory implementations that produce families of related objects (order senders and market data feeds) without exposing the specific exchange implementations to calling code. Strong solutions carefully manage object ownership via smart pointers, implement all virtual methods, and ensure the concrete classes properly satisfy their interface contracts. Pay attention to how factories compose with their products and how a trading system would instantiate the correct factory at startup based on configuration or runtime selection.
- Separation of object creation from usage
- Virtual destructors and memory safety in polymorphic hierarchies
- Smart pointer semantics and ownership transfer
- Designing parallel class hierarchies (factories and products)