Skip to content

item76: 가능한 한 실패 원자적으로 만들라#152

Merged
joona95 merged 3 commits intomainfrom
joona95
Dec 26, 2025
Merged

item76: 가능한 한 실패 원자적으로 만들라#152
joona95 merged 3 commits intomainfrom
joona95

Conversation

@joona95
Copy link
Contributor

@joona95 joona95 commented Dec 18, 2025

closed #148

  • 🙆🏻 내용을 이해하기 쉽고 정확하게 작성하였는가?

  • 📚 글 하단에 예상질문, 참고자료를 포함시켰는가?

  • 🔖 라벨은 등록했는가?

  • ✅ 이슈는 닫았는가?

@joona95 joona95 self-assigned this Dec 18, 2025
@joona95 joona95 added the 예외 label Dec 18, 2025
Comment on lines +131 to +135
### 질문

Q. 실패 원자성이란 무엇인가요?

Q. 실패 원자성을 확보하는 방법 5가지를 나열해보세요.
Copy link
Member

Choose a reason for hiding this comment

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

  1. 메서드가 예외를 던진다면, 호출부에서 전달한 매개변수나 static 인자가 메서드 실행 전 상태로 복구되어야하는 성질
  2. 답:
  • 불변 객체 사용하기
  • 메서드 앞단에서 전제조건 검사하기
  • 실패 가능성 있는 작업을 메서드 앞단에서 실행하기
  • 복구 코드 작성하기
  • 임시객체에서 작업을 끝낸 후 마지막에 교체하기

Comment on lines +133 to +135
Copy link
Contributor

Choose a reason for hiding this comment

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

Q1. 메서드 호출이 실패하더라도, 객체의 상태는 호출 이전과 동일하게 유지되어야 한다
Q2.

  • 불변 객체 사용
  • 매개변수 유효성 검사를 먼저 수행
  • 상태 변경은 마지막에 수행
  • 예외 발생 시 복구 코드 작성
  • 임시 객체에서 작업 후 성공 시 교체


### 질문

Q. 실패 원자성이란 무엇인가요?
Copy link
Contributor

Choose a reason for hiding this comment

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

메서드 호출이 실패했을 경우 객체의 상태는 호출 이전과 동일해야 한다.


Q. 실패 원자성이란 무엇인가요?

Q. 실패 원자성을 확보하는 방법 5가지를 나열해보세요.
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. 불변 객체 사용
  2. 매개변수 유효성을 먼저 검사
  3. 상태 변경은 마지막에 검사
  4. 실패 시 복구 코드 작성
  5. 임시 객체에서 작업 후 교체

Comment on lines +133 to +135
Q. 실패 원자성이란 무엇인가요?

Q. 실패 원자성을 확보하는 방법 5가지를 나열해보세요.
Copy link
Contributor

Choose a reason for hiding this comment

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

A1)
실패원자성은 메서드 호출이 실패하더라도, 객체의 상태는 호출 이전과 동일하게 유지되어야 한다는 의미이다

A2)

  • 불변 객체 사용
  • 매개변수 유효성 먼저 수행
  • 상태 변경은 마지막에 검사
  • 실패 시 복구 코드 작성
  • 임시 객체에서 작업 후 교체

@joona95 joona95 merged commit 07cb2a5 into main Dec 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

item76: 가능한 한 실패 원자적으로 만들라

5 participants