Thinking in Patterns chapter 10: Connecting different types

Thinking in Patterns with Java V0.9: chapter 10: Connecting different types: TIPatterns.htm#_Toc41169731

1, The sections name of today's learning;

Adapter. 84

Bridge. 87

Exercises. 93

2, What is it talk about in these sections and my comments and feeling for the content:

Maybe, I have gotten most feeling in this chapter. After some reading and thinking, I think I have understood these two patterns. In addition, through this chapter, I have known a little more about Proxy pattern.

1), Adapter

From my feeling, Adapter can be seen as a generlization of Proxy, and Proxy is a specific of Adapter. My understanding is below:(UML diagram is at the end of this diary)

1>, From the example: adapter:SimpleAdapter.java for Adapter and the example: proxy:ProxyDemo.java for Proxy, we can see little difference between them;

2>, From the example: adapter:AdapterVariations.java for Adapter, I haven't seen a little piece of Proxy.

Then, let us see their effects:

Proxy: fronting for another object

Adapter: Connecting different types

So, I can say in Proxy pattern: the proxy object and the implementation object these two types objects are connected by the Proxy pattern;

And, Adapter has more usage, it can unite different objects to achieve a job.

Review Bruce's words about proxy(in the end of section: Proxy: fronting for another object in chapter: Object decoupling): Of course, it isn’t necessary that Implementation have the same interface as Proxy; as long as Proxy is somehow “speaking for” the class that it is referring method calls to then the basic idea is satisfied (note that this statement is at odds with the definition for Proxy in GoF).

Then look at this statement at the end of this section: I’m taking liberties with the term “proxy” here, because in Design Patterns they assert that a proxy must have an identical interface with the object that it is a surrogate for. 

Maybe, I have found the reason of GoF's "assert that a proxy must have an identical interface with the object that it is a surrogate for. ", only in this way, Proxy pattern can be a standalone pattern in 23 patterns, otherwise, maybe it can be mixed into adaper, then, there are only 22 patterns exist now:)

And, maybe, Proxy has been used long time by people, we can't ignore its existence, it must be a standalone pattern. And, its work focuses on "fronting for other".

I can't express my entire feeling with my poor english, maybe, writing my diary in english is an error?

2), Bridge:

The most feeling in this chapter is: don't think that authority's words is all right, including GoF's. Bruce got a result after listening some other's idea about Bridge pattern, this result is: GoF's Design Patterns did "a miserable job of describing Bridge", and, there is only one place in GoF's Design Patterns is a lightspot-Bruce says continuely:"except in one place not the general structure chart describing the pattern, which wasn't helpful, but in the structure chart describing their specific example. Only if you stare at that for a bit does Bridge begin to make sense.". From this only lightspot, Bruce put up with a example of his Bridge pattern (and, maybe, is also GoF's), and, at least, I know the Bridge pattern is "often a construct that is used to help you write code. ", and it's goal is "to allow you to structure your code so that you can easily add new kinds of front-end objects which are implemented with functionality in new kinds of back-end objects."

An another meaningful statement for me is "But keep in mind that the vector of change with Bridge is typically happening at coding time: it keeps your code organized when you are dealing with an increasing number of options for implementing functionality."

Bridge pattern is a bridge between "front-end objects" and "back-end objects", regardless the number and the type of all these objects, it can provide an interface at front-end, receive all other front-end objects' requests and hand these requests to back-end interface, and it provides an interface at back-end, receive the requests which come from the front-end interface and hand these requests to back-end objects to fulfill the requests.  

3, My questions about the program itself;

1), the real application of these two patterns;

2), exercises;

4, My questions about the english language;

1), Strange words:

adaptee, take liberty with, unenlightened, begin by, conference, perspectives, give (a) talk, armed with, misinformation, delve, miserable, construct, in common, delegate, combinatorial, bookkeeping, clerking, associative, radically, Effectively

===============================================================================

//: proxy:ProxyDemo.java

// Simple demonstration of the Proxy pattern.

********************************************************************

//: adapter:SimpleAdapter.java

// "Object Adapter" from GoF diagram

********************************************************************

//: adapter:AdapterVariations.java

// Variations on the Adapter pattern.

********************************************************************

//: bridge:BridgeStructure.java

// A demonstration of the structure and operation

// of the Bridge Pattern.

********************************************************************

demonstrate the structure of Bridge

=================================================================================

                          incomplete