java - Proxy & Memento Patterns -


Proxy - what code (and where) does the proxy service in RealService call translate? Why / when using it? Layers - How to Apply? Memento - Why not only release the state in a cache or file?

My understanding of the Proxy pattern is that you have any type of service interface proxy service and RealService is for some reason, you can not access RealService for any reason, so you code against the example ProxyService and then the framework for the actual service of your service For example, proxy can link. Only two problems:

  • When I can access service and ProxyService , but I can not think of an example Real S service - can there be an example when this can happen?

    How is this different from memento pattern? My understanding of the definition of memento is that it is used to save an object condition, what a proxy is really doing, yes? If not, then please tell how Memento is different from the proxy! Thanks in advance!

    First of all, I warn your answer by saying that I do not believe in the pattern There are no hard and fast rules - whatever you want them and do not take anything else, the way I use certain patterns is undoubtedly different how another developer can use them.

    < Strong> Proxy Pattern Explained

    The way I design the proxy design pattern I use you to do this for two things:

    1. Restrict access to public ways of a particular object instance
    2. Immediately by concrete, otherwise Prevent expensive, and unnecessary instantaneous costs Object on the first call for the proxy, then pass all the proxies through the concrete instance.

      Maybe there is a method in RealService is definitely dangerous () which you want to hide or even more blasphemy, There may be several hundred modes in RealService , whenever you type you do not need to look every time. After the example of a RealService variable name. You will use a proxy for any of these.

      To read more, this article has a great deal of information:

      Inter-Random Pattern with

      Memento pattern allows you to roll back an object in its original state or in some previous state by storing intermediate states with concrete objects. Sorting as "Undo" for programming You might use the proxy pattern to apply Memento , but proxy Does not guarantee the saving of the position of the object or the rollback - it only gives you

      Hope it helps - I think that Memento is more complete Must understand as the version. Proxy , but not all proxy are applicable Mementos .

Comments