출처 : 네이버의 어떤 블로그 (좀 되어서 기억이 안나네요.. ㅡ.ㅡ)
Effective C++
50 Specific Ways to Improve Your Programs and Designs
Scott Meyers
Contents
| |||
Prefer const and inline to #define . | |||
Prefer <iostream> to <stdio.h> . | |||
Prefer new and delete to malloc and free . | |||
Prefer C++-style comments. | |||
| |||
Use the same form in corresponding uses of new and delete . | |||
Use delete on pointer members in destructors. | |||
Be prepared for out-of-memory conditions. | |||
Adhere to convention when writing operator new and operator delete . | |||
Avoid hiding the "normal" form of new . | |||
Write operator delete if you write operator new . | |||
| |||
Declare a copy constructor and an assignment operator for classes with dynamically allocated memory. | |||
Prefer initialization to assignment in constructors. | |||
List members in an initialization list in the order in which they are declared. | |||
Make sure base classes have virtual destructors. | |||
Have operator= return a reference to *this . | |||
Assign to all data members in operator= . | |||
Check for assignment to self in operator= . | |||
| |||
Strive for class interfaces that are complete and minimal. | |||
Differentiate among member functions, non-member functions, and friend functions. | |||
Avoid data members in the public interface. | |||
Use const whenever possible. | |||
Prefer pass-by-reference to pass-by-value. | |||
Don't try to return a reference when you must return an object. | |||
Choose carefully between function overloading and parameter defaulting. | |||
Avoid overloading on a pointer and a numerical type. | |||
Guard against potential ambiguity. | |||
Explicitly disallow use of implicitly generated member functions you don't want. | |||
Partition the global namespace. | |||
| |||
Avoid returning "handles" to internal data. | |||
Avoid member functions that return non-const pointers or references to members less accessible than themselves. | |||
Never return a reference to a local object or to a dereferenced pointer initialized by new within the function. | |||
Postpone variable definitions as long as possible. | |||
Use inlining judiciously. | |||
Minimize compilation dependencies between files. | |||
| |||
Make sure public inheritance models "isa." | |||
Differentiate between inheritance of interface and inheritance of implementation. | |||
Never redefine an inherited nonvirtual function. | |||
Never redefine an inherited default parameter value. | |||
Avoid casts down the inheritance hierarchy. | |||
Model "has-a" or "is-implemented-in-terms-of" through layering. | |||
Differentiate between inheritance and templates. | |||
Use private inheritance judiciously. | |||
Use multiple inheritance judiciously. | |||
Say what you mean; understand what you're saying. | |||
| |||
Know what functions C++ silently writes and calls. | |||
Prefer compile-time and link-time errors to runtime errors. | |||
Ensure that non-local static objects are initialized before they're used. | |||
Pay attention to compiler warnings. | |||
Familiarize yourself with the standard library. | |||
Improve your understanding of C++. |
*. 그 동안 Scott Meyers의 Effective C++ 을 맘대로(^^) 정리해봤습니다. 원서를 샀던 관계로 내용을 정리하는데 시간이 많이 걸렸네요. 혹시 이 책을 사실 분들 중 시간이 촉박하지 않다거나 영어를 잘 하시는 분들이라면 꼭 원서로 보시기 바랍니다. 아쉽게도 번역서에는 저자의 재밌는 문체가 살아있지 않은 것 같더군요. 이만큼 재밌게 쓰여진 책도 드문데 말이죠. ^^
'Development > C/C++' 카테고리의 다른 글
[펌] ThreadWaitForMultipleObjects를 쓸 때는 _beginthread를 안쓰.. (0) | 2011.08.13 |
---|---|
[펌] Observer pattern (C++) (0) | 2011.08.13 |
[펌] C++ 기초 강좌 (0) | 2011.08.13 |
[펌] 펌) C++ Programming HOW-TO (0) | 2011.08.13 |
[펌] 메모리 할당 메소드 비교 (0) | 2011.08.13 |
안정적인 DNS서비스 DNSEver