TAILIEUCHUNG - Lecture Software design and architecture – Chapter 29

In this chapter, the following content will be discussed: Design pattern classifications, structural design pattern, adapter pattern, structural design patterns, façade pattern, watch a movie with ease, façade - consequences, individual classes. | SOFTWARE DESIGN AND ARCHITECTURE LECTURE 29 Review Design pattern classifications Structural Design Pattern Adapter Pattern Outline Structural Design Patterns Façade Pattern Structural Patterns deal with the composition of classes or objects. Structural class patterns: use inheritance to compose classes Structural object patterns: describe ways to assemble objects. Façade Pattern Façade Pattern Problem There may be undesirable coupling to many things in the subsystem, or the implementation of the subsystem may change. What to do? Façade – Example (Home Theater) Façade - Example Starting the HomeTheater Put the screen down Turn on the projector Dim the lights Set the projector input to DVD Turn the amplifier on Set the amplifier to DVD input Turn the DVD player on Start the DVD Player playing Turning everything off at the end Complex task to listen music When upgraded or new things added, you would have to learn new steps Lights, Camera, Façade! A Façade is what you need. With the façade pattern, you can take a complex subsystem and make it easier to use by implementing a façade class that provides a reasonable set of interfaces. Watch a movie with ease Façade - Definition Provides a unified interface to a set of interfaces in a sub-system. Defines a higher level interface that makes the subsystem easier to use. Facade Problem There may be undesirable coupling to many things in the subsystem, or the implementation of the subsystem may change. What to do? Solution Define a single point of contact to the subsystem facade object that wraps the subsystem. This facade object presents a single unified interface and is responsible for collaborating with the subsystem components Facade Facade Façade - Consequences It shields clients from subsystem components, thereby reducing the number of objects that clients deal with and making the subsystem easier to use It promotes weak coupling between the subsystem and its clients. Weak coupling lets you vary the components of the subsystem without affecting its clients It doesn't prevent applications from using subsystem classes if they need to. Façade vs. Adapter With both the Facade and Adapter pattern, we have preexisting classes. With the Facade, however, we do not have an interface we must design to, as we do in the Adapter pattern. We are not interested in polymorphic behavior with the Facade; whereas with the Adapter, we probably are. In the case of the Facade pattern, the motivation is to simplify the interface. With the Adapter, although simpler is better, we try to design to an existing interface and cannot simplify things even if a simpler interface were otherwise possible. Façade Pattern - Example Individual Classes Façade Class * Summary Structural Design Patterns Façade Pattern

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.