Perhaps the most important avoidance technique is to know what you're doing.
사실 위 한 문장으로 Chapter 8
의 내용이 압축된다: 너 자신을 알라.
Thinking' is the cause of all error; I can prove this by the fact that whoever makes a mistake always says, "Oh, but I thought..." Never mind this kind of thinking - Bbefore you glue anything together you must know. Put the parts together without glue (called a 'dry run'), study how they fit, and check with your drowing, which shows how everything fits.
- David Jacques Way
깊은 통찰력, 진정한 지성: Thinking is the cause of all error.
Not only will this help you understand what you mean when you come back to the program, but it will also make things easier if someone else has to look at it later.
코드는 한번 작성되고, 여러번 읽힌다.
This applies both to figuring out how programs work and to testing them. So many programs fail when some part of their input is empty or has only one element that those are the cases to try first.
Stick to the well-known parts of the language. By doing that, you will make it easier to move your program to a new machine or compiler and make it less likely that you will run into compiler bugs.
Remember, your programs may well outlast your machine.
코드는 감가상각이 일어나는 공산품이 아니다. 이러한 제품은 원래의 공급자가 사라진 뒤에도 판매가치가 지속되거나 오히려 더 높아질 수 있다.
- 성당과 시장 (Eric S. Raymond), 130pg.
Don't assume any more about your users or your implementation than you have to.
Defensive Programming 의 중요성.
뒤의 남은 내용은 이전 장 Exercise
의 Answer
고 그 뒤의 Appendix
는 Library facilities
에 대한 설명이므로 생략한다. Appendix
부분은 varargs
와 stdarg
부분만 집중해서 보면 될 듯 하다. 그 외 printf family
는 다른 C Library 서적에서 더 자세하게 설명하므로 생략한다.
[Site] https://www.itworld.co.kr/news/95751
[Site] https://en.wikipedia.org/wiki/Defensive_programming
[Book] 성당과 시장 (Eric S. Raymond)
[Book] C Traps and Pitfalls (Andrew Koenig)