Đang chuẩn bị liên kết để tải về tài liệu:
Professional Java JDK 6 Edition 2007 phần 3
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Kích đúp vào một dòng cho phép các điểm kiểm soát được chỉnh sửa, như trong Hình 16.4. Các điểm kiểm soát được di chuyển bằng cách kéo chúng với con chuột. Dòng chế độ chỉnh sửa bằng cách chọn một đối tượng, hoặc bằng cách nhấn vào một nơi nào đó khác trên diện tích sandbox. | Part I Thinking Like a Java Developer Figure 3-4 An inheritance loop is referred to as reaching up the hierarchy as depicted in Figure 3-4. By reaching up the hierarchy you create a relationship known as reverse containment. By holding a collection of a superclass from one of its subclasses it is possible to manipulate different subtypes as well as collections with the same interface. Figure 3-5 shows one subtle change to the example in Figure 3-4. By changing the cardinality of the association between the super- and subtypes to many-to-many it is possible to represent graphs as well as trees. Figure 3-5 Finally Figure 3-6 adds subtype relationships to the inheritance loop allowing the representation of a complex data structure with methods that can be invoked with a polymorphic interface. You have also created a common interface for each responsibility allowing you to add new responsibilities with limited impact to the application. The purpose of this section was to learn tricks to understanding patterns. By creating associations and using inheritance you have been able to build some complex designs from these principles. You learned to apply these principles by remembering simple actions push to the right push up and reach up. Learning these tricks will help you understand the well-known patterns in the next section. 130 Chapter 3 Exploiting Patterns in Java Important Java Patterns This section shows examples of very important and well-known patterns. By learning each of these patterns you will develop your pattern vocabulary and add to your software design toolbox. Each pattern discussed subsequently includes a description of the problem the pattern solves the underlying principles of design at work in the pattern and the classes that make up the pattern and how they work together. The focus of this section is not to describe patterns in a traditional sense but instead to provide code and concrete examples to demonstrate the types of problems that each pattern .