1 / 10

Unit 7 Generic Interfaces and Encapsulation, a Class in the Middle

Unit 7 Generic Interfaces and Encapsulation, a Class in the Middle. Kirk Scott. This is an introductory unit. These are the units/chapters belonging to this section of the course : Unit 8, Mediator, book chapter 10. Unit 9, Façade, book chapter 4. Unit 10, Adapter, book chapter 3.

catori
Télécharger la présentation

Unit 7 Generic Interfaces and Encapsulation, a Class in the Middle

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Unit 7Generic Interfaces and Encapsulation, a Class in the Middle Kirk Scott

  2. This is an introductory unit. • These are the units/chapters belonging to this section of the course: • Unit 8, Mediator, book chapter 10. • Unit 9, Façade, book chapter 4. • Unit 10, Adapter, book chapter 3.

  3. What will be given next is an extremely brief overview of these topics. • The idea is to show that according to the organizational scheme for the course, they can be treated as belonging together, even though the book’s organizational scheme put them into chapters that were separated from each other.

  4. Mediator • Book definition: The intent of the Mediator pattern is to define an object that encapsulates how a set of objects interact; this promotes loose coupling, keeping the objects from referring to one another explicitly, and lets you vary their interactions independently. • Comment mode on: • By definition, a mediator is something that is “in the middle”, between other things. • In object-oriented terms, it’s a class in the middle in terms of functional interactions between classes.

  5. Façade • Book definition: • The intent of the Façade pattern is to provide an interface that makes a subsystem easy to use • Comment mode on: • This, of course, sounds deceptively simple. • How hard it is to make things easy to use… • The façade will be a class with a set of straightforward methods which make calls to methods in underlying classes.

  6. Adapter • Book definition: • The intent of Adapter is to provide the interface that a client expects while using the services of a class with a different interface • Comment mode on: • My joke about adapter is that adapter is the one true pattern. • All other patterns, by intent, if not structure, are adapters.

  7. The idea of having one class provide an interface for another is in some sense fundamental. • In essence, we’ve seen it in embryonic form in patterns we’ve looked at already. • A proxy has adapter-like characteristics. • Mediator and façade also have adapter-like characteristics, and that’s why these three patterns are grouped together

  8. In summary: • Mediator defines the interactions between classes • Façade provides a nice interface for a class or set of classes • Adapter implements the interface needed by a client in order to use a class with a different interface • In one way or another, these patterns all have something to do with providing an interface or functionality that support the relationship between one class and another.

  9. As you will see when the patterns are presented, these are concise mnemonic devices for their most important characteristics: • Mediator: The class in the middle, the class that stands between, the class that defines the interactions among classes. • Façade: The class that stands in front, providing a user-friendly interface. • Adapter: The jack of all trades; the class that makes one class usable by another.

  10. The End

More Related