Design Patterns in Ruby by Russ Olsen

Design Patterns in Ruby by Russ Olsen

Author:Russ Olsen
Language: eng
Format: epub, pdf
Publisher: Pearson Education Limited (US titles)
Published: 2008-03-19T16:00:00+00:00


proxy = BankAccountProxy.new(account)

proxy.deposit(50)

proxy.withdraw(10)

* * *

There really is nothing very exciting going on in BankAccountProxy. The BankAccountProxy presents exactly the same interface as its subject, the BankAccount object. But the proxy doesn’t really know a thing about high finance—whenever someone calls a method on it, the BankAccountProxy turns to the real BankAccount object, delegating the method call to the subject.

Of course, if our proxy did nothing more than echo every call blindly down to the subject, we will not have accomplished much except create a sink for those extra CPU cycles as the method calls arrive at the proxy, only to be immediately bounced off to the subject. But once we have a proxy, we have a place to stand squarely between the client and the real object. If we want to manage who does what to the bank account, the proxy provides the ideal pinch point to exert control.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.