TAILIEUCHUNG - Java Design Patterns A Tutorial phần 3

Giả sử rằng bạn đang viết một chương trình để hỗ trợ các chủ nhà ở bổ sung thiết kế ngôi nhà của họ. Những đối tượng nào một mô hình Nhà máy có thể được sử dụng để sản xuất?Chương trình thực tế bạn xây dựng sử dụng các lớp này một cách thông thường, có phương pháp riêng của nó khá khác nhau. | Programs on the CD-ROM Program Description Builder Constructs the last box and check box multiple choice panels discussed in this chapter. 57 Chapter 8. The Prototype Pattern With the Prototype pattern you can specify the general class needed in a program but defer specifying the exact class until execution time. It is similar to the Builder pattern in that some class decides what components or details make up the final class. However it differs in that the target classes are constructed by cloning one or more prototype classes and then changing or filling in the details of the cloned class to behave as desired. Prototypes can be used whenever you need classes that differ only in the type of processing that they offer for example when parsing strings that represent numbers in different radixes. In this sense the Prototype is nearly the same as the Exemplar pattern described by Coplien 1992 . Let s consider the case in which you need to make a number of queries to an extensive database to construct an answer. Once you have this answer as a table or ResultSet you might want to manipulate it to produce other answers without your having to issue additional queries. For example consider a database of a large number of swimmers in a league or statewide organization. Each swimmer swims several strokes and distances throughout a season. The best times for swimmers are tabulated by age group. Within a single four-month season many swimmers will have birthdays and therefore move into new age groups. Thus the query to determine which swimmers did the best in their age groups that season depends on the date of each meet and on each swimmer s birthday. The computational cost of assembling this table of times is therefore fairly high. Once you have a class containing this table sorted by sex you might want to examine this information sorted by time or by actual age rather than by age group. Recomputing this data isn t sensible and you don t want to destroy the

TỪ KHÓA LIÊN QUAN
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.