> For the complete documentation index, see [llms.txt](https://dev-lambda.gitbook.io/tech-interview-cs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dev-lambda.gitbook.io/tech-interview-cs/design-patern/observerpattern.md).

# 옵저버 패턴

## 옵저버 패턴이란

* 주체가 어떤 객체의 상태 변화를 관찰
* 객체의 상태 변화가 있을 때마다 메서드 등을 통해 옵저버 목록에 있는 옵저버들에게 변화를 알려줌
  * ex) 트위터 특정인물을 follow 하고 있으면, 해당 인물이 포스팅을 올리는 것을 관찰하고 있다가, 포스팅시 팔로워들에게 노티를 준다.
  * ex) MVC 모델: 모델에서 변경 사항이 생길시, update() 메서드로 옵저버인 뷰게 알려준다. 이ㄹ 기반으로 컨트롤러가 작동한다.

### 상속

* 자식 클래스가 부모 클래스의 메서드 등을 상속
* 상속받은 메서드 등에 추가 및 확장하여 활용
* 재사용성 중복성의 최소화
* 일반 클래스, abstract 클래스 기반으로 구현

### 구현

* 부모 인터페이스를 자식 클래스에서 재정의하여 구현
* 상소과 달리 반드시 부모 클래스의 메서드를 재정의하여 구현하야한다.
* I/F 기반으로 구현


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://dev-lambda.gitbook.io/tech-interview-cs/design-patern/observerpattern.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
