T
T
topuserman2020-12-02 10:41:01
OOP
topuserman, 2020-12-02 10:41:01

How to solve an architectural problem?

I have a User class which has a getStatus method .

An object of this class is used both independently and is a dependency of another entity - Group .

There was a need to make it so that the result of the getStatus method can change depending on some state of the Group entity .

How it is correct architecturally to solve it?

So that the user entity can work on its own, but if it is in the context of another entity, so that it can change the result of the ?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
montray, 2020-12-02
@quiex

Read about the Law of Demeter

S
soloveid, 2020-12-07
@soloveid

Well, you yourself have come to a better solution.
There must be an entity that groups users and groups, and it is she who will
know how the user is connected and where he belongs, respectively, the getStatus method should be hers.
So you do not complicate the current solution (bells and whistles in the User and Group classes), but add new functionality
by adding new code (do you know such a principle?)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question