The Purpose of Encapsulation
Số trang: 1
Loại file: pdf
Dung lượng: 21.38 KB
Lượt xem: 17
Lượt tải: 0
Xem trước 1 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
Mục đích của Tóm lược Tóm lược là một nguyên tắc quan trọng khi xác định các lớp học. Ý tưởng là một chương trình sử dụng một lớp học không nên phải lo lắng làm thế nào lớp mà thực sự hoạt động nội bộ; chương trình chỉ đơn giản là tạo ra một thể hiện của một lớp, và gọi các phương thức của lớp đó.
Nội dung trích xuất từ tài liệu:
The Purpose of Encapsulation The Purpose of EncapsulationEncapsulation is an important principle when defining classes. The idea is that a programthat uses a class should not have to worry how that class actually works internally; theprogram simply creates an instance of a class, and calls the methods of that class. As longas those methods do what they say they will do, the program does not care how they areimplemented. For example, when you call the Console.WriteLine method, you dont wantto be bothered with all the intricate details of how the Console class physically arrangesfor data to be output to the screen. A class might need to maintain all sorts of internalstate information in order to perform its various methods. This additional stateinformation and activity is hidden from the program that is using the class. Therefore,encapsulation is sometimes referred to as information-hiding. Encapsulation actually hastwo purposes: 1. To combine methods and data inside a class; in other words, to support classification. 2. To control the accessibility of the methods and data; in other words, to control the use of the class.
Nội dung trích xuất từ tài liệu:
The Purpose of Encapsulation The Purpose of EncapsulationEncapsulation is an important principle when defining classes. The idea is that a programthat uses a class should not have to worry how that class actually works internally; theprogram simply creates an instance of a class, and calls the methods of that class. As longas those methods do what they say they will do, the program does not care how they areimplemented. For example, when you call the Console.WriteLine method, you dont wantto be bothered with all the intricate details of how the Console class physically arrangesfor data to be output to the screen. A class might need to maintain all sorts of internalstate information in order to perform its various methods. This additional stateinformation and activity is hidden from the program that is using the class. Therefore,encapsulation is sometimes referred to as information-hiding. Encapsulation actually hastwo purposes: 1. To combine methods and data inside a class; in other words, to support classification. 2. To control the accessibility of the methods and data; in other words, to control the use of the class.
Tìm kiếm theo từ khóa liên quan:
ngôn ngữ lập trình lập trình ngôn ngữ C# C# Summarizing Keyword Combinations The Purpose of EncapsulationGợi ý tài liệu liên quan:
-
Giáo trình Lập trình hướng đối tượng: Phần 2
154 trang 271 0 0 -
Kỹ thuật lập trình trên Visual Basic 2005
148 trang 263 0 0 -
Bài thuyết trình Ngôn ngữ lập trình: Hệ điều hành Window Mobile
30 trang 263 0 0 -
Giáo trình Lập trình cơ bản với C++: Phần 1
77 trang 231 0 0 -
Bài giảng Một số hướng nghiên cứu và ứng dụng - Lê Thanh Hương
13 trang 221 0 0 -
Giáo án Tin học lớp 11 (Trọn bộ cả năm)
125 trang 214 1 0 -
NGÂN HÀNG CÂU HỎI TRẮC NGHIỆM THIẾT KẾ WEB
8 trang 203 0 0 -
Bài tập lập trình Windows dùng C# - Bài thực hành
13 trang 179 0 0 -
Giáo trình Lập trình C căn bản: Phần 1
64 trang 169 0 0 -
Bài giảng Nhập môn về lập trình - Chương 1: Giới thiệu về máy tính và lập trình
30 trang 163 0 0