tailieunhanh - Programming - Software Engineering The Practice of Programming phần 8
hoàn toàn, thời gian dành cho di động như chương trình được tạo ra sẽ được đền đáp khi phần mềm phải được cập nhật. Thông điệp của chúng tôi là thế này: cố gắng để viết phần mềm làm việc trong các giao điểm của các tiêu chuẩn khác nhau, giao diện và môi trường phải phù hợp. Không sửa chữa mọi vấn đề tính di động | 190 PORTABILITY CHAPTER8 completely time spent on portability as the program is created will pay off when the software must be updated. Our message is this try to write software that works within the intersection of the various standards interfaces and environments it must accommodate. Don t fix every portability problem by adding special code instead adapt the software to work within the new constraints. Use abstraction and encapsulation to restrict and control unavoidable non-portable code. By staying within the intersection of constraints and by localizing system dependencies your code will become cleaner and more general as it is ported. Language Stick to the standard. The first step to portable code is of course to program in a high-level language and within the language standard if there is one. Binaries don t port well but source code does. Even so the way that a compiler translates a program into machine instructions is not precisely defined even for standard languages. Few languages in wide use have only a single implementation there are usually multiple suppliers or versions for different operating systems or releases that have evolved over time. How they interpret your source code will vary. Why isn t a standard a strict definition Sometimes a standard is incomplete and fails to define the behavior when features interact. Sometimes it s deliberately indefinite for example the char type in C and C may be signed or unsigned and need not even have exactly 8 bits. Leaving such issues up to the compiler writer may allow more efficient implementations and avoid restricting the hardware the language will run on at the risk of making life harder for programmers. Politics and technical compatibility issues may lead to compromises that leave details unspecified. Finally languages are intricate and compilers are complex there will be errors in the interpretation and bugs in the implementation. Sometimes the languages aren t standardized at all. C has an .
đang nạp các trang xem trước