tailieunhanh - Java Design Patterns A Tutorial phần 5

Tuy nhiên, từ quan điểm của nhà xây dựng, tất cả họ đều xuất hiện để được giống. Sử dụng các mô hình cầu có những hậu quả sau đây: 1. Các mô hình cầu là nhằm mục đích để giữ cho giao diện chương trình khách hàng của bạn liên tục trong khi cho phép bạn thay đổi các loại thực tế của lớp học mà bạn hiển thị hoặc sử dụng. | If you name the Data Source something other than Grocery Prices you will need to change the corresponding name in line 20 of . lightbulb Thought Question 1. Suppose that you have written a program with a File Open menu a text field and some buttons controlling font bold and italic . Now suppose that you need to have this program run from a line command with arguments. Explain how you would use a Faẹade pattern to accomplish this. Programs on the CD-ROM Programs Description F aẹade dbFrame .java Reads in the database and displays the grocery tables as illustrated in the text. 113 Chapter 14. The Flyweight Pattern In this chapter we take up the Flyweight pattern which is used to avoid the overhead of large numbers of very similar classes. Sometimes you need to generate a very large number of small class instances to represent data. You can greatly reduce the number of different classes that you need to instantiate if you can determine that the instances are fundamentally the same except for a few parameters. If you can move those variables outside of the class instance and pass them in as part of a method call you greatly reduce the number of separate instances by sharing them. The Flyweight pattern provides an approach for handling such classes. It refers to the instance s intrinsic data that make the instance unique and the extrinsic data that are passed in as arguments. The Flyweight is appropriate for small fine-grained classes such as those for individual characters or icons on the screen. For example you might be drawing a series of icons on the screen in a window with each icon representing a person or data file as a folder as shown in Figure . Figure . A set of folders representing information about various people. Their similarity makes them candidates for the Flyweight pattern. In this case it doesn t make sense for each folder to have an individual class instance that remembers the person s name and the icon s screen .

TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
10    182    3    03-01-2025