AWS App Design, 3
A commercial product should support differentiation by a key; it should load sets of subclasses for that key. The key can be a customer, an account, a car model, a product. This pattern has several forms - Abstract Factory, Factory of Factories, Inversion of Control, Dependency Injection but they share the same goal.
API pseudo-code for AbstractFactory:
createEngine(key='Tesla') {
AbstactFactory af = new AbstractFactory()
return af.createFactory(key).createEngine()
}
AbstractFactory pattern eliminates error-prone branching ("if..else") logic. The intermediate Factory class supports a stateful API:
Car car = createCar()
// maintains factory state between calls
CarFactory tf = af.createFactory('Tesla')
car.engine = tf.createEngine()
car.axle = tf.createAxle()
AD1: Infrastructure with Cloud Formation
AD2: Messaging I/O
AD3: Abstract Factory
AD4: Database
AD5: Application Layer - Aspects
AD5: Application Layer - Canonical
AD5: Application Layer - Data Mapping
AD5: Application Layer - Protocol Adapter
AD6: Security