ServiceOne.java
private void doStuff(){}
ServiceTwo.java
private void doStuff()
Where to put common code ?
Shall I create a new service, but then what interface will it implement ?
Or shall I just create a utility class ? Please guide on what is the best approrach.
2
Well it actually depends on the stuff. If the stuff is related to the business logic of the application and inside has to do with domain objects then it has to go in another class and be aggregated in the services or depending on domain in a superclass of both services. For example both services need to check if a user already exists.
On the other hand if that method has nothing to do with business logic, it could go in a utility class. For example suppose it has to poll a given function, calling it multiple time until response is not null.
2