iluwatar / java-design-patterns

Design patterns implemented in Java
https://java-design-patterns.com
Other
89.53k stars 26.47k forks source link

May I ask what design pattern is best for this kind of business? #2873

Closed xufei56789 closed 4 months ago

xufei56789 commented 6 months ago

未命名文件 (1)

AritraThakurta commented 5 months ago

@iluwatar I think it would be best if we use Visitor Design Pattern

SahithyaCherukuri commented 4 months ago

@iluwatar I believe the Factory design pattern better matches this business model (and if you plan on using encapsulation to determine the category of the object, this is the best pattern).

Take a look at this link for more information about Factory Pattern (https://refactoring.guru/design-patterns/factory-method)