1

Off the top of my head i am thinking of writing my server-side tasks as one big service and injecting all dao objects within that service- something like this:

public class MyServiceImpl extends RemoteServiceServlet implements MyService {
@Inject 
MyDAO1 myDAO1;
@Inject 
MyDAO2 myDAO2;
@Inject 
MyDAO3 myDAO3;

...
//20  methods
//
}

Is one big service the way to go or is there some other, better pattern for this ?

osh
  • 1,191
  • 4
  • 13
  • 21
  • I think this covers it: http://stackoverflow.com/a/16234079/210445 – pillingworth Sep 11 '13 at 14:41
  • 3
    @osh, no, one large service is not good since it violates [single responsibility principle](http://en.wikipedia.org/wiki/Single_responsibility_principle). You are essentially creating god object which would be very hard to support. You should think about which responsibilities your server-side layer has and then you should carefully divide these responsibilities among several services. – Vladimir Matveev Sep 11 '13 at 18:19

1 Answers1

0

You should buid a service for each "domain" of tasks. For example, a service for User Management, with methods that allows registering new users, send recovering password e-mails, disable temporarily a user, get a list of currently enabled users, etc.

I suggest you take a look at the ServiceLayer pattern described on Martin Fowler's Patterns of Enterprise Application Architecture (http://martinfowler.com/books/eaa.html).

A Service Layer defines an application's boundary [Cockburn PloP] and its set of available operations from the perspective of interfacing client layers. It encapsulates the application's business logic, controlling transactions and coor-dinating responses in the implementation of its operations (http://martinfowler.com/eaaCatalog/serviceLayer.html)

dgimenes
  • 892
  • 11
  • 23