Creating related but independent products
Imagine you’re building an action platformer with two main crafting systems, one for regular items, armor, and weapons, and another for special fusion products. Each crafting system needs to have the same basic capabilities for buying, selling, crafting, and disassembling items. On top of that, your team needs to be able to interact with each crafting system through a common set of interfaces but be able to switch them out at any time without breaking existing code (whenever new DLC comes out, I’m guessing).
Scripting product interfaces
The first component of the Abstract Factory pattern is the abstract product interfaces. In our example, we not only have two different sets of capabilities – buying/selling and crafting/disassembling, which leads to a nice (and sensible) separation of interfaces for our factories – we’ll let the merchant products handle buying and selling, and the blacksmith products...