tailieunhanh - C# 3.0 Design Patterns PHẦN 4

Các mô hình chính của chúng tôi sẽ xem xét trong chương này là các mô hình Adapter. Đây là một mô hình linh hoạt tham gia cùng loại không được thiết kế để làm việc với nhau. Đây là một trong những mô hình mà đi kèm hữu ích khi giao dịch với mã di sản | CHAPTER 4 Structural Patterns Adapter and Facade The main pattern we will consider in this chapter is the Adapter pattern. It is a versatile pattern that joins together types that were not designed to work with each other. It is one of those patterns that comes in useful when dealing with legacy code . code that was written a while ago and to which one might not have access. There are different kinds of adapters including class object two-way and pluggable. We ll explore the differences here. The second pattern we will look at in this chapter the Facade pattern is a simple one that rounds out the structural group. The aim of this pattern is to provide a simplified interface to a set of complex systems. Adapter Pattern Role The Adapter pattern enables a system to use classes whose interfaces don t quite match its requirements. It is especially useful for off-the-shelf code for toolkits and for libraries. Many examples of the Adapter pattern involve input output because that is one domain that is constantly changing. For example programs written in the 1980s will have very different user interfaces from those written in the 2000s. Being able to adapt those parts of the system to new hardware facilities would be much more cost effective than rewriting them. Toolkits also need adapters. Although they are designed for reuse not all applications will want to use the interfaces that toolkits provide some might prefer to stick to a well-known domain-specific interface. In such cases the adapter can accept calls from the application and transform them into calls on toolkit methods. Illustration Our illustration of the Adapter pattern is a very real one it involves hardware instruction sets not input output. From 1996 to 2006 Apple Macintosh computers 74 ran on the PowerPC processor. The operating system was Mac OS X. But in April 2006 Apple started releasing all new Apple computers iMacs Minis and MacBooks with Intel Core Duo processors. Mac OS X was rewritten to target

TỪ KHÓA LIÊN QUAN
crossorigin="anonymous">
Đã 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.