I have a problem that seems to me to be fairly common. The problem, in this case, is this: the user wants to register in the system the services available for sale together with the values. When you sell a service, you want the service to become active for the customer.
Finally, for some services there are specific rules and properties that the system needs to consult. An example would be support service, which has the hours that the customer pays per month. This service has a specific rule: it can only be performed if the hours have not yet been spent in the month, and have a specific property: the number of hours.
Now let's see the problem: if the user registers the services manually, there is no way in the system to know for example which service is the support service. In fact, for the system they will all be the same. This is because in theory there will be a single class with general properties, whose instances are services registered for sale.
This clearly conflicts with having to specify rules and details for specific types of service.
As I said, I think this may be more common than it seems at first. I quoted a concrete case, but we could abstract it as follows: the user wants to register some objects in a personalized way, however these objects need to have specific behaviors, with specific properties and specific rules, which conflicts with the user wanting to register them at will .
In this sense, the solution that I identified was the following: identify the service types, create a class for each type, and in the registry ask the user to choose the type, opening possibility of customization. Here it seems that would fit the use of inheritance, but I know that this is subtle.
Other than that I thought of the bounded contexts of the DDD. I wondered if the problem was not the term "Service" being used in two different contexts, representing different things. The problem is that despite identifying the problem, I have not identified how to deal with the "service type" issue.
As this seems to me common, I thought if there was a design pattern that deals with this. Is this kind of a design pattern issue? Is there a known and tested solution that addresses this type of problem?
Or the solution I proposed to create a class for each type of service, abstracting its main characteristics, allowing the user to choose the type in the register would be the best solution?