Visual Basic 2005 Design and Development - Chapter 10

Custom Controls and Components Có lẽ lợi ích quan trọng nhất của lập trình hướng đối tượng là đóng gói. Đóng gói, hoặc che giấu thông tin, bảo vệ các chi tiết nội bộ của một lớp từ con mắt tò mò. Nó cách ly các phần còn lại của chương trình từ những thay đổi bên trong của lớp. Có lẽ lợi ích lớn nhất của tất cả các đóng gói cho phép các nhà phát triển làm việc với một lớp học bỏ qua các chi tiết của lớp. Bạn có thể sử dụng một đối tượng mà. | Custom Controls and Components Perhaps the most important benefit of object-oriented programming is encapsulation. Encapsulation or information hiding protects the internal details of a class from prying eyes. It insulates the rest of the program from changes to the class s internals. Probably the biggest benefit of all is that encapsulation lets developers working with a class ignore the details of the class. You can use an object without needing to keep track of how the class works so that you can focus on other things. Imagine trying to keep all of the details of a 100 000-line program in your head at the same time You need to be able to ignore as much of the program as possible while you focus on the part you are writing. Controls and components provide excellent encapsulation. They can encapsulate complicated behavior and allow developers to interact with them only through properties methods and events. If the controls are compiled rather than included within the main program then the encapsulation is fairly tight. It s not as easy for developers to peek inside a compiled control or component and take advantage of its internals possibly tying themselves to a particular implementation of the control. Controls and components are also extremely common items in Visual Basic development. Even a relative novice knows how to use a control s properties methods and events. Controls and components provide such tight encapsulation they work particularly well when your project involves developers at different locations. One developer can build a control and other developers can use it. The separation of the control s code and the main program s code helps keep the developers work decoupled and creates a design-by-contract atmosphere almost all by itself. I ve used this approach on a couple of projects very successfully. Part II Meta-Development Of course controls and components are just special kinds of libraries so you can gain similar advantages by using compiled .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã 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.