I’ve been working a lot with PHP.
But recently I was assigned some work which uses Java. In PHP I used to do a lot of Singleton object but this pattern has not the same signification in Java that it has in PHP.
So I wanted to go for an utility class (a class with static method) but my chief doesn’t like this kind of classes and ask me to go for services object.
So my guess was that a service object is just a class with a constructor that implement some public methods…
Am I right?
Domain-Driven Design defines a Service as:
Yes, it’s a class with public methods, but in addition to that, it implements an interface that exposes those methods. At its core, the Service is the interface – the class that implements it is just an implementation detail.