클린 코드 룰북
                                            
                                                
                                                
                                                
                                                
                                                
                                                 9274 단어  cleanjavascriptcode
                    
변수 이름
의미가 있는 변수 이름:
Wrong
let x = priceValidation(0);Right
let isPriceValid = priceValidation(0);
단수 및 복수
Wrong
let person = ['John', 'Mary', 'Luke']; let persons = 'Adam';Right
let persons = ['John', 'Mary', 'Luke']; let person = 'Adam';
함수는 동사입니다
Wrong
const total = (a, b) => a + b;Right
const calcTotal = (a, b) => a + b;
될 것인가 말 것인가...
Wrong
const greenColor = ( color === 'green');Right
const isGreenColor = ( color === 'green');
WTH는 273.15입니다.
Wrong
const kelvinDegrees = 24 + 273.15;Right
const celsiusDegrees = 24; const kelvinScale = 273.5; const kelvinDegrees = celsiusDegrees + kelvinScale;
풀네임으로 불러주세요.
Wrong
const names = [ 'John Smith', 'Mary Smith', 'Luke Smith' ]; const namesWithLastNameSmith = names.filter ( (x) => { //code ... });Right
const names = [ 'John Smith', 'Mary Smith', 'Luke Smith' ]; const namesWithLastNameSmith = names.filter ( (name) => { //code ... });
오류, 경고 및 정보.
뭔가 잘못?
Wrong
const isOver18YearsOld = age > 17; if( isOver18YearsOld ) { showMessage('Is Something wrong :('; }Right
const isOver18YearsOld = age > 17; if( isOver18YearsOld ) { showMessage('Sorry, You must be over 18 years old.'; }
프로덕션에서 디버깅:O
Wrong
throw new Error(‘Unexpected Error’);Right
throw new Error(‘someFile.js:someFunction: undefined value in variable’);
이 RuleBook을 계속 업데이트하고 있습니다.
Reference
이 문제에 관하여(클린 코드 룰북), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/edisonsanchez/clean-code-rulebook-35mp텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)