This is a good example of parts of a template. The basic construction of objects is a worthy example, but the logic relies on a single Computer.ComputerType enumeration. This listing should know in advance, each type of computer that is exposed to each factory.
Often the motivation for using an abstract factory is to abstract this type of hard-coded requirement from an image. Instead of having a single enumeration, it would be better to add a ComputerType class and let the factory return a collection of available types. You can then use the returned ComputerType to build new systems.
This allows you to add other factories without changing your API, which is one of the main advantages of the abstract factory pattern. Read Annotation factory A sample is one of the highlights:
The client does not know (or does not care) about which specific objects he receives from each of these internal plants, since he uses only the common interfaces of his products.
In this case, you βhard codeβ the known types into an enumeration, which violates this part of the template.
Reed copsey
source share