Do you need a singleton ?
According to the GoF, the intent of a singleton is:
to ensure that a class has only a single instance and to provide
an access point to it.
But is there a reason that justifies that a
RequestUser really has to be unique across your application ? Or was it just a design choice because it was convenient to easily find back the active user, assuming that the client would be for a single user ? And if so, can't you imagine a future version of your client that would connect to several information sources and combine them, thus needing several active
Don't use a singleton, unless you really have to. The convenience of finding it back is more than outweighed by the many hidden dependencies that it favors.
Is it really inheritance ?
It's not clear to me, if:
RequestUser inherits from
Request because you have a stateful backend and
RequestUser is really a distinct
- or if you just want
RequestUser to inherit from a couple of behaviors, such as for example formatting an URL part that will be combined with other parts to build the real request.
In the first case, the inheritance is fine. In the second, it's not a safe design, and you should favor composition. In both cases though, you create a structural dependency between your client and the back-end logic in terms of sequence of operations and communication scheme.
Alternative design: the mediator
You may decouple your components much more by opting for the mediator pattern.
With this pattern, the user, the event and other request topics would become colleagues, inheriting from a base class that provides the common behavior.
A mediator would then encapsulate the interactions between the colleagues. That object, and that object only, would then have to find the current user objet for the current request and manage these kind of dependencies explicitly.
It may be difficult to change your current frame of thinking. However this pattern is really worth the investment: because once the mediator encapsulate the interactions, you no longer have to care if it's a stateful or a stateless back-end in any other places of your code: the mediator would combine the behaviors as required.