Answer the question
In order to leave comments, you need to log in
What pattern to apply in this situation?
All good day! The task conditions are as follows.
There is a class representing a person. Its implementation in this context is absolutely not important. A person can be awarded certain awards. Accordingly, the reward is a separate class, most likely it will be abstract, and inherited in descendants (each descendant for a certain type of reward).
The problem is the following. All five generating patterns that we can see in the gang of four - work with properties like isCallable, isDrawable, etc., that is, in fact, when declaring such properties, we say what interface is implemented in this class. Even if t.s. from a humanitarian point of view, look - "mobile" = "can move", "edible" = "can be eaten", etc.... In my case with awards, this epithet is inappropriate - because it turns out something like "green" = "?", "high" = "?" etc. More specifically, in the class of awards there are such properties as "when received", "issued by", "type of award", "certifying document", "certifying document number", etc., and this type of field varies depending on the type of reward (some must be included in the class, some not). How appropriate is the use of an abstract factory, builder, or prototype (and if so, what exactly to use?), Are patterns needed here, and is it generally advisable to use OOP here?
Answer the question
In order to leave comments, you need to log in
IMHO, you are confused. The "strategy" pattern suffices here. Factories and builders are needed for large projects that are planned to be maintained and expanded for a long time, a prototype is not the topic at all - it is needed when copying an existing object is easier than constructing a new one (for example, if there are many calculated fields).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question