tailieunhanh - Visual Basic 2005 Design and Development - Chapter 15

Coding Standards Tiêu chuẩn mã hóa những quy tắc mà các nhà phát triển theo để làm cho mã của họ phù hợp hơn. Phù hợp mã dễ dàng hơn để đọc, vì vậy phát triển có thể hiểu và sửa đổi nó một cách nhanh chóng hơn với ít cơ hội giới thiệu các lỗi mới. Ví dụ, giả sử tôi xây dựng một ứng dụng có sử dụng một hộp Tên văn bản đầu tiên. Thiết lập các tiêu chuẩn riêng của tôi nói rằng hộp văn bản nên được đặt tên txtFirstName, nhãn hiệu liên quan nên. | Coding Standards Coding standards are rules that developers follow to make their code more consistent. Consistent code is easier to read so developers can understand and modify it more quickly with less chance of introducing new errors. For example suppose I build an application that uses a First Name text box. My particular set of standards says the text box should be named txtFirstName the associated label should be named lblFirstName and if I need to copy the text entered in the text box into a variable the variable should be named first_name. If I see any of those items txtFirstName lblFirstName or first_name in the code I know exactly what they are. Similarly if I see items such as txtstreet IblBillingCity or cboState I immediately know what the values are for even without studying the code in detail. That makes my understanding of the code faster and more accurate. The object names in the previous paragraph use standard prefixes to indicate the types of objects that they represent. These are txt for TextBox lbl for Label and cbo for ComboBox. The section Component Names later in this chapter lists other object prefixes. It is important that all of the programmers on your project follow the same coding standard so that they can more easily read and understand each other s code. It is less important however what standard you adopt. Consistency is the important thing not whether you name variables using Pascal case FirstName camel case firstName or lowercase with underscores first_name . The important thing is that all of the developers follow the same rules. Standards are also useful for preventing arguments. As strange as it seems some developers can become quite heated when discussing the merits of Hungarian notation camel casing and the other niceties of coding conventions. Having a well-defined standard can defuse some of these arguments before they start. I ve never worked on a project where these sorts of arguments were much of an issue. If someone found

TỪ KHÓA LIÊN QUAN
crossorigin="anonymous">
Đã 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.