코드 가독성

1. if문 다음에 나오는 공통된 절차를 각 분기점 내부에 넣는다. --> 공통된 절차는 조건에 상관없이 무조건 실행 되어야 하므로. function test() { let result = ''; if(a) { if(!b) { result = 'c'; } } else { result = 'a'; } result += 'b'; return result; } function test() { let result = ''; if(a) { if(!b) { result = 'c'; } result += 'b'; return result; } else { result = 'a'; result += 'b'; return result; } } 2. 분기점에서 짧은 절타부터 실행하게 if문을 작성한다. --> if와 el..
ya_ya
'코드 가독성' 태그의 글 목록