다른 개발자들에게 API를 제공한다는 마음으로 개발하라
남이 봐도 쉬운 코드를 만들어라
'역사적'인 이유를 만들지 말아라
자신의 코드만 보지 말아라
기존의 코드와 통일성 있는 코드를 작성하라
커뮤니케이션 하라
항상 '1년 뒤에 이 소스를 본다면?' 이라고 생각하라 
리팩토링 하라 


패턴그리고객체지향적코딩의법칙
카테고리 컴퓨터/IT > 프로그래밍/언어
지은이 문우식 (한빛미디어, 2007년)
상세보기

  

Tail recursion

Posted by epicdev Archive : 2011. 9. 8. 01:02
  

const identifiers are often better than #define because:

they obey the language’s scoping rules
you can see them in the debugger
you can take their address if you need to
you can pass them by const-reference if you need to
they don’t create new “keywords” in your program.
In short, const identifiers act like they’re part of the language because they are part of the language. The preprocessor can be thought of as a language layered on top of C++. You can imagine that the preprocessor runs as a separate pass through your code, which would mean your original source code would be seen only by the preprocessor, not by the C++ compiler itself. In other words, you can imagine the preprocessor sees your original source code and replaces all #define symbols with their values, then the C++ compiler proper sees the modified source code after the original symbols got replaced by the preprocessor.

There are cases where #define is needed, but you should generally avoid it when you have the choice. You should evaluate whether to use const vs. #define based on business value: time, money, risk. In other words, one size does not fit all. Most of the time you’ll use const rather than #define for constants, but sometimes you’ll use #define. But please remember to wash your hands afterwards.

  
 «이전 1 ··· 50 51 52 53 54 55  다음»