What is a Service Class? And what would a Service be in that context?

Asked

Viewed 406 times

1

What would be the best formal definition for Class of Service? Still in this context, what would be a Service and the conditions for this class to be named? I realized that is a term widely used but I did not find a formal definition for the concept here at Sopt.

  • For now I closed like this, but I can change the reason or reopen. I thought it had already been answered before. There are many contexts where you can use that term even within IT.

  • there are many uses, in programming and operating systems, which sometimes mix, outside services in the understanding of X company provide a "port" to Y company, I see as nothing "standard" to relate to this, of course, there are Apis, protocols and parameters/instructions used for communication, which would be the basic to define this as a service, which is usually always "active" somewhere, may be that a response appears, even speaking of SOAP or REST, to try to contextualize as programming, but there will be people using the term in the most absurd situations (I think)

  • I can edit asking in the context of web programming and of software engineering? Because in the answer that @Maniero link gave me in the post of OCP, where I put a Service class, he questioned if it would really be a service, and it made me question whether my definition is correct or not.

  • There is not even a question of defining what is a service, but if that would be a class of service, but already started to give a context, going this way the question begins to improve.

  • This is my question, when a class can be called a service class and what would be the conditions for it to be named? And so that I, and future users, can understand this, it would be interesting to have a definition of service in this context.

  • I edited the question, I hope it is suitable now for the standards of the site and can serve to be answered.

  • @Maniero the question became adequate?

  • I can not understand why so many negative votes, is a question that has not yet been formally answered here at Sopt and people instead answer negatively.

Show 3 more comments

1 answer

2


There is a bit of controversy about what is and there are different contexts even for the service class. For example if using the DDD discipline it has a clear definition of what it proposes, which does not mean that it should be the definition of other people and there are those who question all this.

Martin Fowler criticizes the use of classes that model anemic objects, So it just has the structure and it doesn’t have behaviors that stay in well-segregated service classes. So he says that the services should be additional to the basic model, but it’s not clear what the limit is.

Some will say is that one can be called in more than one place, but not always this is clear in advance in the project, in theory it is beautiful, in practice it only works by coincidence, so many people prefer to only have services, in doubt it is separate.

In a sense, we can think of a sort of normalization. If used only in one place and you can guarantee this must be in the class that is used, whether in the model, controller or elsewhere. If it can be used in more than one place then it needs its own entity to deal with it and make the relationship with everything that needs it. A service class is one that has behaviors that do not fit into other classes naturally and encapsulated.

I believe that these service classes are linked to the domain and the class used in the question is linked to the controller (I don’t know if it should, it could be an error, I can’t say).

That is, it proposes to forget this object orientation business because the procedural has always been good when done correctly and in a modular way. Or almost this, some people will contest this.

Interestingly, these classes are usually similar to or equal to the classes utilitarian or help (helper) that many criticize exists, but that they play an important role. Some give slightly different definitions for this, but still maintain similarity, although a service should be something more specific. Some say the difference is that the service is something well defined, while a helper is gambiarra, but it seems to me a definition of "mark territory".

I’ve seen contradictory definitions of the term.

My love-hate relationship with D.O.D.is like this, I still don’t fully master discipline and I always say she has really good ideas, corrects too much error or formulates a technique that helps people make better code, But it goes a little too far and then the implementation makes any code very complex, so the implementation of the idea is not good. I do some things that maybe one day I can organize and create a framework (the chance is not so great for lack of time) that use the DDD base in a better way.

No way you can create a service class only if you are using DDD.

Then in the question linked has an example using a service class, but I don’t know if this is a service because service is not well defined. But I also don’t know why it doesn’t have all the context, if it makes sense there because I didn’t see the domain (model), and as it is written there has problems in the code and does strange things, which begins to indicate that it is not a service, it mixes responsibilities of the model with the action of the controller, Worst mixture more of a model inappropriately. Maybe it’s just a service not well implementing, but still being a service. The idea was good.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.