-
Notifications
You must be signed in to change notification settings - Fork 2
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
[오혜성] 챕터 4: 액션에서 계산 빼내기 #19
The head ref may contain hidden characters: "\uCC55\uD1304/\uC624\uD61C\uC131"
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# 액션에서 계산 빼내기 | ||
* 액션은 코드 전체로 퍼지기 쉽다 | ||
+ 어떤 함수 안에 액션이 하나만 있어도 그 함수 전체가 액션이 됨 | ||
|
||
## 함수의 입력과 출력 | ||
|
||
* 입력과 출력은 명시적이거나 암묵적일 수 있다 | ||
+ 인자와 리턴값은 명시적이고 | ||
+ 인자 외의 입력과 리턴값 외의 다른 출력은 암묵적이다 | ||
|
||
* 암묵적 입력과 출력이 있으면 액션이 된다 | ||
|
||
* 테스트와 재사용성은 입출력과 관련있다 | ||
|
||
|
||
## 액션에서 계산 빼내기 | ||
|
||
* 기존 함수에서 동작을 뺴내어 서브루틴을 추출해 계산으로 만들 수 있음 | ||
+ 코드가 더 많아진 거 같은데요? | ||
- 일반적으로 더 적은 코드가 좋지만, 서브루틴을 추출해 테스트하기 쉽고 재사용하기 좋은 코드가 될 수 있음. | ||
|
||
* 다른 곳에서 쓰기 위해서가 아니더라도 계산으로 분리하면 좋나? | ||
+ 좋다. 작은 것은 테스트하기 쉽고, 재사용하기 쉽고, 이해하기 쉽기 때문 | ||
|
||
## 계산 추출을 단계별로 알아보기 | ||
|
||
1. 계산 코드를 찾아 뺀다 | ||
2. 새 함수에 암묵적 입력과 출력을 찾는다 | ||
3. 암묵적 입력은 인자로, 암묵적 출력은 리턴값으로 바꾼다 | ||
|
||
> 현실 세계에서 적용하는 방법은? | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
리액트 기준 컴포넌트 레벨로 생각해보는것도 괜찮을 것 같아요!