Pregunta

Besides the interface of Remote Facade pattern being more coarse-grained and clients calling this interface being remote rather than local, are there any other differences between the two patterns?

Thank you

¿Fue útil?

Solución

Are you referring to a Remote interface like Java's RMI? I don't think that is a facade but actually a proxy pattern implementation.

the Remote forwards all calls (hidden from the user via the proxy pattern) to a different machine. This hides from the user the fact that the work is not being done locally.

Facade pattern usually simplifies a complicated interface to a more simplified version (like a substituting a complicated control panel with a different control panel with only the a few of the most used buttons). If you really need the more complicated version, you can still use the old more complicated controls instead.

EDIT After you pointed out that you are referring to Marin Fowler's Remote Facade I will explain further:

Fowler's Remote Facade is not just Remote + Facade patterns. There is also a extra reasoning behind the simplifications the facade uses.

Instead of just simplifying complicated methods or removing under used methods from the facade. RemoteFacade is explicitly used to combine several common methods in the "unfacaded" interface to reduce latency and network traffic.

Since Remote calls will go over the network (using Java's RMI etc) there is a lot of overhead to convert the method call into a message to pass over the network. It takes time for the message to go over the network and get a message back and unmarshal the response etc. There might also be security layers checking and intercepting the traffic as well. All add to the amount of time and effort to call the remote method.

RemoteFacade combines several common methods into a single network message. So using Fowler's example from his book, if you have an interface for Address with separate setters for setCity() setZipcode(), setStreet(). That would be 3 remote calls to go over the network. Instead RemoteFacade turns that into 1 method setAddress(street, city, zip) which will only require 1 networked message passed and therefore it should take less time to invoke.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top