Here is the use of this design
I need to publish some APIs so that the external world can configure the user and its services. Configuring the user mainly includes the creation of new user based on the input params (like id, password, level etc) and creating a new connection object. Once the user object is created, service configuration is required. It's a two step process - enabling service, modifying service details. Modifying service details is composed of a set of actions. These actions are specific to only that service. These actions will be different for other services.
Here is my current implementation
A user class is composed of service_manager, connection, group classes. service_manager class manages set of services (say ServiceA, ServiceB ... ServiceN). There is a seaparate class for each service.
user class has a public function assignService. This function takes an argument, required to identify the service class. It return an object of the respective service class. Here is an pseudo code for the same.
serviceObjectA = user.assignService ('A');
Later, this service object can be used to perform actions, specific to that service.
serviceObjectA.performActionA1(...);
serviceObjectA.performActionA2(...);
serviceObjectA.performActionA10(...);
Here is the issue, I am facing with this implementation:
a) the performAction function needs few attributes of the user class (like id, password, location etc) and the connection object. These user attributes are required to prepare the request. The connection object is required to send this request over the already created connection. Currently, I am managing it in the service class constructor, wherein, I am passing these user attributes and connection object as the constructor arguments. It's becoming little bit unmanagable as various service classes require different user attributes.
Please suggest some alternative to this.
b) Is it really a good practice to exposing the service object to the outside world?
I am still new to the OOP world, so apologies if I understood anything incorrectly. I will be really great if you can demonstrate it with a pseudo example.