tailieunhanh - Lập trình Wrox Professional Xcode 3 cho Mac OS part 24

Bạn có thể cần phải tổ chức lại hệ thống các lớp học của bạn, di chuyển chức năng từ lớp này sang lớp khác, tận dụng lợi thế của các tính năng ngôn ngữ mới, hoặc chỉ cần đổi tên biến sao cho nó phản ánh chính xác hơn mục đích của nó. Các loại thay đổi được gọi là tái cấu trúc mã của bạn. | 10 Refactoring WHAT S IN THIS CHAPTER Renaming classes types methods functions and variables Reorganizing code and restructuring classes Modernizing your code Despite our best efforts class and data structures don t always endure. New features requirements operating system evolution and improvements elsewhere in your application may cause you to revisit the design of your existing class and data architecture. You may need to reorganize the hierarchy of your classes migrate functionality from one class to another take advantage of new language features or simply rename a variable so that it more accurately reflects its purpose. These kinds of changes are referred to as refactoring your code. Making structural changes to your code using the editor and the search and replace tools can often be tedious time consuming and error prone. In the days before refactoring I would often rename or relocate an instance variable by simply changing its declaration and then hunting down and correcting all of the compilation errors that resulted not the most productive way to spend an afternoon. Fortunately Xcode now provides a refactoring tool that helps you make many common structural changes to your application quickly and succinctly. It uses the Code Sense database and an inherent knowledge of C and Objective-C syntax to intelligently rename symbols reorganize classes and streamline code. This chapter describes the kinds of changes the refactoring tool performs and the steps required. Refactoring is formally defined as a change to the internal structure of your program that doesn t change its external or functional behavior. The reality is that any change no matter how careful can have unintended consequences. The section Refactoring Pitfalls discusses some of these potential problems how to address them and some best practices. Download at 186 CHAPTER 10 REFACTORING REFACTORING WORKFLOW To refactor something in your project follow these general steps 1. Select .

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.