일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
- Sentry
- 이미지바꾸기
- Visual Studio Code
- php
- JavaScript
- error
- Ionic
- 자바스크립개념
- VSCode
- Git
- ChangeDetectorRef
- typescript
- change detection
- zsh
- code .
- oh-my-zsh
- angular5
- NVM
- getElementsByClassName
- angular
- sealize
- 테두리굵기
- fromEvent
- border-width
- 변화감지
- IONIC3
- ion-range
- hashchange
- rxjs
- aab 배포
- Today
- Total
hsunny study blog
1.5 Magic Number 본문
Magic number
Magic number ->
constants, array sizes, character positions, conversion factors,
and other literal numeric values that appear in programs.
Give names to magic numbers.
raw number in program source gives no indication of its importance or derivation, making the program harder tounderstand and modify.
Define numbers as constants, not macros.
in C: #define int MAXROW = 24. MAXCOL = 80;
in C++: const int MAXROW = 24. MAXCOL = 80;
in JAVA: static final int MAXROW = 24, MAXCOL = 80;
A related issue is that the number 0 appears often in programs, in many contexts.
So, don't write
? str = 0;
? name[i]=0;
? x=0;
but rather:
str = NULL;
name[il = '\0';
x = 0.0;
We prefer to use different explicit constants, reserving 0 for a literal integer zero,
because they indicate the use of the value and thus provide a bit of documentation.
W O R D
constant 정수
conversion factors
opaque 불투명한, 이해하기 힘든
derivation 어원
blunt 무딘, 뭉툭한
lexical 어휘의
underfoot 발밑에
'book > The Practice of Programming' 카테고리의 다른 글
1.6 Comment (0) | 2015.12.28 |
---|---|
1.4 Function Macros (0) | 2015.12.23 |
1.3 Consistency and Idioms (0) | 2015.12.22 |
1.2 Expressions and Statements (0) | 2015.12.21 |
1.1 Names (0) | 2015.12.21 |