TAILIEUCHUNG - C Programming for the Absolute Beginner phần 5

Tham khảo tài liệu 'c programming for the absolute beginner phần 5', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Chapter 5 Structured Programming a function that contains the logic and structures to handle this procedure and then reuse that function when needed. Putting all the code into one function that can be called repeatedly will save you programming time immediately and in the future if changes to the function need to be made. Let me discuss another example using the printf function which you are already familiar with that demonstrates code reuse. In this example a programmer has already implemented the code and structures needed to print plain text to standard output. You simply use the printf function by calling its name and passing the desired characters to it. Because the printf function exists in a module or library you can call it repeatedly without knowing its implementation details or in other words how it was built. Code reuse is truly a programmer s best friend Information Hiding Information hiding is a conceptual process by which programmers conceal implementation details into functions. Functions can be seen as black boxes. A black box is simply a component logical or physical that performs a task. You don t know how the black box performs implements the task you just simply know it works when needed. Figure depicts the black box concept. Figure Demonstrating the black box concept. Consider the two black box drawings in Figure . Each black box describes one component in this case the components are printf and scanf . The reason that I consider the two functions printf and scanf black boxes is because you do not need to know what s inside of them how they are made you only need to know what they take as input and what they return as output. In other words understanding how to use a function while not knowing how it is built is a good example of information hiding. Many of the functions you have used so far demonstrate the usefulness of information hiding. Table lists more common library functions that implement information hiding in structured

Đã 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.