In the explanation of the AbstractFactory pattern, we often see examples of passing a character string as a runtime argument or making an if-else judgment with a flag.
In personal development, you may not care because you know everything. However, if it is provided as a module to other teams in team development, How do you know which Factory the team that received the Factory can generate?
I think the method is either to check the code yourself or to check with the person in charge of the code on the Factory side.
The person in charge on the Factory side, whether for the code person in the client, Whether it's because it's a hassle to answer when you come to ask yourself ** Please be aware that "Enums can clearly show what can be generated" **.
When implemented using Enum, it explicitly indicates the Factroy to be generated, and it will not generate a Factory that does not exist. * The following code is my own improvement of the TECH SCORE Abstract Factory pattern. Please include that it has nothing to do with TECH SCORE. </ span> 8. AbstractFactory pattern
-Since only Factroy existing in Enum can be generated, an erroneous Factory will not be generated. -For team development, the client-side code manager does not need to know what the Factory class can be generated. If the Factory class is missing, all you have to do is ask the programmer in charge of the Factory side. -Easy to add Factory. Since you only need to add the required Factory class to the Enum, there is no need to modify the if statement.
If you write the program by yourself, you don't have to think about this, but ** If you work as a team and you are in charge of dividing modules By thinking in this way, the ease of change can be improved and modularization can be facilitated. ** **