Eliminating Bugs Before They Hatch
Số trang: 2
Loại file: pdf
Dung lượng: 18.30 KB
Lượt xem: 2
Lượt tải: 0
Xem trước 2 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
Trước khi loại bỏ lỗi Họ Hatch Viết code không phải là điều bạn muốn làm trong khi nửa ngủ. Như các bạn đã có thể có kinh nghiệm, Flash là không hề khoan nhượng khi nó diễn giải các tập lệnh bạn thêm vào một dự án.
Nội dung trích xuất từ tài liệu:
Eliminating Bugs Before They Hatch < Day Day Up >Eliminating Bugs Before They HatchWriting code is not something you want to do while half asleep. As youve probablyexperienced, Flash is unforgiving when it interprets the script you add to a project.Seemingly tiny errors such as a faulty line of script or even a misspelled word can have adamaging domino effect on the rest of the code in your project. These minor problems areexperienced by scripters of all skill levels. Most problems can usually be solved by a tapon the Backspace key. But if errors are hidden deep inside your code, youll find yourselfstaring at it for hours, pulling out your hair, and yelling at your dog (maybe even pullingout your dogs hair if things get really out of control). Sometimes the simplest problemcan be the largest contributor to a stressful development cycle.One of the best ways to avoid many problems is to be aware of what they are. Thefollowing list shows some of the more common mistakes that all scripters make: • Omitting quotation marks in strings. Strings of text should always be identified with quotes. • Misnaming variables, functions, and objects. As your project grows, youll need to keep track of more named items. Its a good idea to adopt a common naming convention, based on your preferences. Some scripters use all lowercase letters and underscores to name variables, such as my_variable and my_other_variable, and in-fix notation (where the first letter of the first word is lowercase, while the first letter in subsequent words is uppercase) for function names such as myFunction() and myOtherFunction(). Other scripters avoid using plural names completely; they dont have to remember whether an elements name has an s at the end. Whatever naming conventions you adopt, consistency is the key. Remember that ActionScript is case-sensitive, so userName and username are not the same. • Omitting quotation marks when comparing string values. When writing a condi tional statement, the concept of using quotes to identify strings sometimes gets lost in our brains as we type. If a conditional statement is not doing what it should, suspect missing quotation marks. • Forgetting case when comparing string values. This is an easy mistake to commit. Remember, this string is not equal to This String. Case must be considered when comparing string values. • Confusing = and ==. A single equals sign assigns a value (this = that). A double equals sign compares values (does this == that?). • Missing or mismatched curly braces around blocks of code. Make sure that the end of a code block has as many closing curly braces (}) as the beginning of the block has opening braces ({). • Omitting the return statement in a function. If a function is meant to return a value,it will be worthless (broken) without a return statement. < Day Day Up >
Nội dung trích xuất từ tài liệu:
Eliminating Bugs Before They Hatch < Day Day Up >Eliminating Bugs Before They HatchWriting code is not something you want to do while half asleep. As youve probablyexperienced, Flash is unforgiving when it interprets the script you add to a project.Seemingly tiny errors such as a faulty line of script or even a misspelled word can have adamaging domino effect on the rest of the code in your project. These minor problems areexperienced by scripters of all skill levels. Most problems can usually be solved by a tapon the Backspace key. But if errors are hidden deep inside your code, youll find yourselfstaring at it for hours, pulling out your hair, and yelling at your dog (maybe even pullingout your dogs hair if things get really out of control). Sometimes the simplest problemcan be the largest contributor to a stressful development cycle.One of the best ways to avoid many problems is to be aware of what they are. Thefollowing list shows some of the more common mistakes that all scripters make: • Omitting quotation marks in strings. Strings of text should always be identified with quotes. • Misnaming variables, functions, and objects. As your project grows, youll need to keep track of more named items. Its a good idea to adopt a common naming convention, based on your preferences. Some scripters use all lowercase letters and underscores to name variables, such as my_variable and my_other_variable, and in-fix notation (where the first letter of the first word is lowercase, while the first letter in subsequent words is uppercase) for function names such as myFunction() and myOtherFunction(). Other scripters avoid using plural names completely; they dont have to remember whether an elements name has an s at the end. Whatever naming conventions you adopt, consistency is the key. Remember that ActionScript is case-sensitive, so userName and username are not the same. • Omitting quotation marks when comparing string values. When writing a condi tional statement, the concept of using quotes to identify strings sometimes gets lost in our brains as we type. If a conditional statement is not doing what it should, suspect missing quotation marks. • Forgetting case when comparing string values. This is an easy mistake to commit. Remember, this string is not equal to This String. Case must be considered when comparing string values. • Confusing = and ==. A single equals sign assigns a value (this = that). A double equals sign compares values (does this == that?). • Missing or mismatched curly braces around blocks of code. Make sure that the end of a code block has as many closing curly braces (}) as the beginning of the block has opening braces ({). • Omitting the return statement in a function. If a function is meant to return a value,it will be worthless (broken) without a return statement. < Day Day Up >
Tìm kiếm theo từ khóa liên quan:
máy tính mạng máy tính internet phần mềm ứng dụng lập trình SQL HTML sever web XMLGợi ý tài liệu liên quan:
-
Giáo án Tin học lớp 9 (Trọn bộ cả năm)
149 trang 263 0 0 -
Ngân hàng câu hỏi trắc nghiệm môn mạng máy tính
99 trang 251 1 0 -
Giáo trình Hệ thống mạng máy tính CCNA (Tập 4): Phần 2
102 trang 244 0 0 -
Bài giảng: Lịch sử phát triển hệ thống mạng
118 trang 244 0 0 -
47 trang 237 3 0
-
Đề cương chi tiết học phần Thiết kế và cài đặt mạng
3 trang 234 0 0 -
80 trang 215 0 0
-
122 trang 212 0 0
-
Giáo trình Hệ thống mạng máy tính CCNA (Tập 4): Phần 1
122 trang 209 0 0 -
Giáo trình môn học/mô đun: Mạng máy tính (Ngành/nghề: Quản trị mạng máy tính) - Phần 1
68 trang 200 0 0