Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shkyung-ch1 #1

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

shkyung-ch1 #1

wants to merge 13 commits into from

Conversation

shkyung
Copy link

@shkyung shkyung commented Apr 28, 2021

No description provided.

@shkyung shkyung changed the title 1.1 sample code in book shkyung-ch1 Apr 28, 2021
@@ -4,28 +4,6 @@ import plays from "./data/plays.json";
const invoice = invoices[0];

function statement() {
function amountFor(aPerformance, play) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

책에서 statement() 함수 안에 nested function으로 amountFor() 를 만든다고 했는데
뒤에 내용을 보니 이렇게 하면 되게 지저분해 질거같은데.. 번역이 잘못된건지 제가 잘못이해한건지 모르겠네요 일단 밖으로 뺍니다 ㅎㅎ

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.5장 50페이지를 보니 statement() 안에 중첩함수들로 만든게 맞군여...ㅎㅎㅎㅎ

@@ -15,16 +15,15 @@ function statement() {
}).format;

for (let perf of invoice.performances) {
const play = plays[perf.playID];
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저는 2,3번 이상 object에 접근하여 값을 가져오는 경우는 변수에 넣어서 사용하고 있었는데 책에서는
이전 코드는 루프를 한번 돌때마다 공연을 조회했는데 반해 리팩터링 한 코드에서는 세번이나 조회한다. 일단 지금 확인한 바로는 이렇게 변경해도 성능에 큰 영향은 없다. 설사 심각하게 느려지더라도 제대로 리팩터링 된 코드베이슨느 그렇지 않은 코드보다 성능을 개선하기가 훨씬 수월하다. 지역변수를 제거해서 얻는 가장 큰 장점은 추출 작업이 훨씬 쉬워진다는 것이다. 라고 하네요

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant