Answer the question
In order to leave comments, you need to log in
Class design advice?
I want to write a class for working with the user's balance, obviously only 2 methods: withdraw, replenish. Question 2:
1. You can simply implement it with a regular class, or you can create an interface, write these 2 methods in it, so the class will have to implement them, so I will get a guarantee that they are implemented in this class. And all the interface in this case will not bring other bonuses? Something is somehow too simple))
2. After topping up the balance, in some cases, the user needs to shift the date until which the use of a certain service is allowed. I understand correctly that this function should be implemented in another class, because this is a different functionality, a different database table, a different data type (date, not money)
Answer the question
In order to leave comments, you need to log in
1. The interface brings a lot of bonuses in terms of architecture. Learn contract programming - understand all the benefits
2. Yes, you understand correctly ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question