I have similar fun task from my university. For example, there is ClassA. I need to limit access to object that if today is sunday client can’t make ClassA object or using existing ClassA objects. I think I need to make some wrapper for class because otherwise I need to make checking conditiong of day in each method of ClassA. Is there any desing patters for it? Please, I hope you can help me.
Share
Factory pattern is what you are looking for. You pass the arguments to a factory class (the “wrapper”) and it takes care of creating the right kind of object. For example:
When you need a new object, MyFactory decides the actual class: