코드 냄새 20 - 조기 최적화
7477 단어 developingcodingcodesmelloop
TL;DR: Don't guess things that might not happen.
문제
솔루션
예
샘플 코드
잘못된
class Person {
ancestors() {
cachedResults = GlobalPeopleSingletonCache.getInstance().relativesCache(this.id);
if (cachedResults != null) {
return (cachedResults.hashFor(this.id)).getAllParents();
}
return database().getAllParents(this.id);
}
}
오른쪽
class Person {
ancestors(){
return this.mother.meAndAncerstors().concat(this.father.meAndAncerstors());
}
meAndAncerstors(){
return this.ancestors().push(this);
}
}
발각
이것은 디자인 냄새이므로 기계 도구로는 (아직) 감지할 수 없습니다.
태그
class Person {
ancestors() {
cachedResults = GlobalPeopleSingletonCache.getInstance().relativesCache(this.id);
if (cachedResults != null) {
return (cachedResults.hashFor(this.id)).getAllParents();
}
return database().getAllParents(this.id);
}
}
class Person {
ancestors(){
return this.mother.meAndAncerstors().concat(this.father.meAndAncerstors());
}
meAndAncerstors(){
return this.ancestors().push(this);
}
}
이것은 디자인 냄새이므로 기계 도구로는 (아직) 감지할 수 없습니다.
태그
결론
기능적 모델이 충분히 성숙해질 때까지 성능 결정을 미루십시오.
Donald Knuth는 최고의/가장 빠른 알고리즘과 데이터 구조를 생성/컴파일했습니다. 큰 지혜로 그는 우리에게 학대에 대해 경고했습니다. 왜 우리가 그보다 똑똑하다고 생각합니까?
처지
코드 냄새 06 - 너무 영리한 프로그래머
Maxi Contieri ・ 2020년 10월 25일 ・ 2분 읽기
#codenewbie
#tutorial
#beginners
더 많은 정보

코드 냄새 06 - 너무 영리한 프로그래머
Maxi Contieri ・ 2020년 10월 25일 ・ 2분 읽기
#codenewbie
#tutorial
#beginners
더 많은 정보

싱글톤: 모든 악의 근원
Maxi Contieri ・ 11월 17 '20 ・ 9분 읽기
#oop
#tutorial
#codenewbie
#programming
학점
사진 제공: Markus Spiske on Unsplash
Premature optimization is the root of all evil.
도널드 크누스
소프트웨어 엔지니어링 좋은 인용구
Maxi Contieri ・ 12월 28일 '20 ・ 13분 읽기
#codenewbie
#programming
#quotes
#software
이 기사는 CodeSmell 시리즈의 일부입니다.
코드에서 냄새 나는 부분을 찾는 방법
Maxi Contieri ・ 2021년 5월 21일 ・ 4분 읽기
#codenewbie
#tutorial
#codequality
#beginners
마지막 업데이트: 2021/07/02
Reference
이 문제에 관하여(코드 냄새 20 - 조기 최적화), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://dev.to/mcsee/code-smell-20-premature-optimization-4moe
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
Premature optimization is the root of all evil.

소프트웨어 엔지니어링 좋은 인용구
Maxi Contieri ・ 12월 28일 '20 ・ 13분 읽기
#codenewbie
#programming
#quotes
#software

코드에서 냄새 나는 부분을 찾는 방법
Maxi Contieri ・ 2021년 5월 21일 ・ 4분 읽기
#codenewbie
#tutorial
#codequality
#beginners
Reference
이 문제에 관하여(코드 냄새 20 - 조기 최적화), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/mcsee/code-smell-20-premature-optimization-4moe텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)