Service Object Responsabilities (comparing it with a Facade Object).
Hello,
I am sorry if this question has been asked more then once. I have just read a book explaining on how to develop a web application using light weight frameworks.
In this book I was introduced to Facade Objects and Service Objects. Before I used to have only service objects (which managed the database session) used directly from my presentation layer. I now understand that this is wrong, and that the Facade Objects should manage the session with the database.
However what I do not understand is what is the responsability of a service object? I really can not understand it.
Could anyone please give me a small example.
Thanks in advance,
Sim085
[699 byte] By [
sim085a] at [2007-10-3 4:02:01]

> Hello,
>
> I am sorry if this question has been asked more then
> once. I have just read a book explaining on how to
> develop a web application using light weight
> frameworks.
>
> In this book I was introduced to Facade Objects and
> Service Objects. Before I used to have only service
> objects (which managed the database session) used
> directly from my presentation layer. I now
> understand that this is wrong,
Why do you think it's wrong?
> and that the Facade
> Objects should manage the session with the database.
What would you say is the difference between a Service and a Facade?
> However what I do not understand is what is the
> responsability of a service object? I really can not
> understand it.
Services are stateless objects that fulfill requests from clients - they do things.Those are your system's use cases.
What does a Facade do? It gives clients a single interface that hides the complexity of what's going on behind.It's a one-way communication between the client and the objects behind the Facade: the client calls into the Facade, which manages the objects behind the scenes, but those objects don't communicate back to the client.
My sense is that Service IS a Facade.
%
I have nothing to say, the previous post has already explained this.
Facade represents a point of access to an applications.
Services are not exposed directly yo the client, otherwise they're exposed through the facade.
I believe all services may represents use cases and each service do some particular task, usually discriminated by package.
The facade is what the client see and the facade implementation will delegate to those services the requests.
Facade and Service are a similar concept, only that facade usually delegates to the properly service that has the behaviour.
> I have nothing to say, the previous post has already
> explained this.
>
> Facade represents a point of access to an applications.
OK
> Services are not exposed directly yo the client,
> otherwise they're exposed through the facade.
If they're not exposed to the client, how can they be useful?
> I believe all services may represents use cases and
> each service do some particular task, usually
> discriminated by package.
> The facade is what the client see and the facade
> implementation will delegate to those services the
> requests.
Sounds like you're saying that Facade is the interface and Service is the implementation of that interface. That's one way to think about it.
> Facade and Service are a similar concept, only that
> facade usually delegates to the properly service that
> has the behaviour.
%
I didn't say the facade is the interface and a service it's implementation.Any facade implementation delegates requests to services implementations.
> I didn't say the facade is the interface and a
> service it's implementation.
I know you didn't - I did.
> Any facade implementation delegates requests to services implementations.
How's that different from an interface? The only difference that I see is that the facade would have implementations of all the same methods as the service, and each implementation would do nothing more than call the corresponding method on the service implementation that it had.
If that's true, the only difference between your idea of a facade and using an interface is that you have to write all those facade methods that pass through to the service.
I think the better idiom is interfaces. Java developers should prefer them in this situation. That's what they're made for.
%