Summary of reading 2.5 chapter 2 for Unix™ Systems Programming: Communication, Concurrency, and Threads
After reading this section of chapter, I found that more and more things need to think a through at some time, especially for the guideline listed below.
-
Make use of return values to communicate information and to make error trapping easy for the calling program.
-
Do not exit from functions. Instead, return an error value to allow the calling program flexibility in handling the error.
-
Make functions general but usable. (Sometimes these are conflicting goals.)
-
Do not make unnecessary assumptions about sizes of buffers. (This is often hard to implement.)
-
When it is necessary to use limits, use standard system-defined limits rather than arbitrary constants.
-
Do not reinvent the wheel—use standard library functions when possible.
-
Do not modify input parameter values unless it makes sense to do so.
-
Do not use static variables or dynamic memory allocation if automatic allocation will do just as well.
-
Analyze all the calls to the malloc family to make sure the program frees the memory that was allocated.
-
Consider whether a function is ever called recursively or from a signal handler or from a thread. Functions with variables of static storage class may not behave in the desired way. (The error number can cause a big problem here.)
-
Analyze the consequences of interruptions by signals.
-
Carefully consider how the entire program terminates.
I can understand most but the not entries. I need more time to think about them. Just share the guide to you all. ^_^
Posted in: programming |
Details
- Paperback: 450 pages
- Publisher: Manning Publications; 1 edition (October 1, 2006)
- Language: English
- ISBN-10: 1932394508
- ISBN-13: 978-1932394504
- Product Dimensions: 9.1 x 7.4 x 1.2 inches
- [DownLoad Link]
Posted in: books |
