Suspense와 ErrorBoundary로 바라보는 객체지향 - 안톨리니 - #3
Open
Antoliny0919 wants to merge 1 commit into
Open
Conversation
vlmbuyd
approved these changes
Aug 1, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
📖 이번 장에서 학습한 내용
메서드와 메시지를 구분하라 !
객체가 다른 객체와 상호작용할 수 있는 유일한 방법은 메시지를 전송 하는 것뿐이다.
다른 객체에게 요청이 도착할 때 해당 객체가 메시지를 수신 했다고 이야기한다.
Screening에서 reserve호출시 calculateFee 호출 caluculateFee에서 movie객체에게 “영화요금 계산해줘” 메시지 전송.(calculateMovieFee)
응답받은 메시지(영화요금)를 기반으로 관객수 * → 계산
여기서 “수신된 메시지를 처리하기 위한 자신만의 방법을 메서드”
즉, Movie객체가
calculateMovieFee라는 메시지를 전달받았고calculateMovieFee라는 메서드를 사용하여 수신된 메시지를 처리했다.Screening이 Movie의 calculateMovieFee “메서드를 호출했다” X
Screening이 Movie에게 calculateMovieFee “메시지를 전송했다” 이에 Movie는 메시지를 처리하기 위해 calculateMovieFee라는 메서드를 호출한다.
메시지 (Message)
객체에게 "이것 좀 해줘"라고 요청하는 행위 자체다.
객체 A가 객체 B에게 무언가를 시킬 때, A는 B에게 메시지를 보내는것.
여기서
order라는 객체에게calculateTotal이라는 메시지를 보낸것이다.메서드 (Method)
그 메시지를 받은 객체가 실제로 실행하는 코드, 즉 요청을 처리하는 구체적인 구현이다.
order객체 내부에 정의된calculateTotal()의 실제 로직(할인 적용하고, 세금 더하고... 하는 코드)이 메서드다.왜 구분해?
핵심은 "메시지를 보내는 쪽은 메서드가 어떻게 생겼는지 몰라도 된다" 는 데 있다.
이 둘을 개념적으로 분리해야 다형성(polymorphism) 이 성립한다. 같은 메시지를 보내도 받는 객체가 누구냐에 따라 다른 메서드가 실행될 수 있다.
예시 ...
draw()라는 같은 메시지 를 보내도,Circle이면 원을 그리는 메서드가,Square면 사각형을 그리는 메서드가 실행된다. 보내는 쪽은 각 객체가 무슨 메서드를 가졌는지 신경 쓸필요 없다. 그냥 "그려줘"라고 메시지만 던질 뿐."메서드와 메시지를 구분하라"는 말은 결국 코드를 짤 때 "객체에게 명령을 내리지 말고, 메시지를 보내서 협력을 요청하라" 는 뜻이된다.
객체를 자율적인 존재로 대하고, 내부 구현(메서드)은 그 객체에게 온전히 맡긴다.
🖥️ 프론트엔드 관점에서의 적용
Suspense와ErrorBoundary를 사용했을때 객체지향 관점으로 생각해본적이 있나요 ?(자세한 내용은 MD파일에 ..)
💬 함께 이야기하고 싶은 점
작성예정 ...