Hey guys,
I'm not having a problem, I was just wondering what's the best way of implementing isSomthing
in OOP paradigm?
Take this example: we want to know if the user was temporarily (like 10 minutes) banned. Here are the two options:
- Implementing
isTempBanned()
method in theUser
class. Then whenever we want to check if user is banned, we just call this method. no change to the other parts of the code is required.
- Adding a isTempBanned property to the User class. Then whenever the state of user's ban changes, we update this property accordingly. Then when we need to know, we just use this property.
Can you explain Pros and Cons of each way? from these standpoints:
- performance
- code maintainability
- clean code
- readability
- etc...