Replace code in abstract factory pattern