Logo

Coding preview

Implement abstract factory

What this preview is

About this preview

Implement abstract factory is a cooked quant coding problem on design patterns in Cpp.

Unlock full access to getcracked

Join to unlock this problem, detailed solutions, and our complete library of quant finance interview prep.

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)