TAILIEUCHUNG - Design Patterns FOR Dummies phần 2

Các mẫu thiết kế Observer về việc chuyển giao các thông báo xung quanh để cập nhật một tập hợp các đối tượng khi một số sự kiện quan trọng đã xảy ra. Bạn có thể thêm các đối tượng quan sát mới tại thời gian chạy và loại bỏ chúng khi cần thiết. Khi một sự kiện xảy ra, tất cả các quan sát viên đã đăng ký được thông báo. | 14 Part I Getting to Know Patterns_ The Observer design pattern is about passing notifications around to update a set of objects when some important event has occurred. You can add new observer objects at runtime and remove them as needed. When an event occurs all registered observers are notified. Figure 1-8 shows how it works an observer can register itself with the subject. Figure 1-8 The Observer pattern lets observers register with subjects. And another observer Observer 2 can register itself as well as shown in Figure 1-9. Figure 1-9 More than one observer can register with a subject. Now the subject is keeping track of two observers. When an event occurs the subject notifies both observers. See Figure 1-10. Figure 1-10 When events occur in the subject registered observers are notified. Chapter 1 Congratulations Your Problem Has Already Been Solved 15 Does this sound familiar in Java If Java event listeners came to mind you d be right. Event listeners can register with objects like push buttons or windows to be informed of any events that occur. That s just one example of the kind of design pattern you ve probably already seen implemented in Java. When such examples come up I include Java example code showing how a particular design pattern is already built into Java. The example code might ring a few bells. This book is written to be easy to use and understand. You re not going to see chalkboard diagrams of complex abstractions that you have to plow through. The chapters in this book are aimed at programmers to be useful for programmers even if you don t read all of them you re going to benefit. The design insights and patterns covered here are becoming standard throughout the programming world and they are helpful on an everyday level. Hopefully the next time you face a tough coding issue you ll suddenly find yourself saying Aha this is a job for the Facade pattern. 16 Part I Getting to Know .

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.