-
Notifications
You must be signed in to change notification settings - Fork 3
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
[줄라이 & 나무 & 고사리] 인터페이스란? #38
Comments
1 질문 같은 경우엔 검색해본 결과 브릿지 패턴이라는 것이 있네요. |
// 외부로 노출할 인터페이스(메서드) methodA(), methodB()
struct SomeStruct {
func methodA() { // 외부에 노출된 인터페이스
methodB() // 구현 세부사항
}
func methodB() { // methodA()의 구현 세부사항이지만 외부로 노출된 인터페이스이기도 함.
// ...
}
}
// 개선?
struct SomeStruct {
func methodA() { // 외부에 노출된 인터페이스
// methodA에서는 methodB의 기능이 필요함
methodA구현()
}
func methodB() { // 외부에 노출된 인터페이스
methodB구현()
}
private func methodA구현() {
methodB구현()
}
private func methodB구현() {
}
} |
찾아보니 브릿지 패턴, 어댑터 패턴 등이 있는 것 같은데 아직 어떻게 적용하는지는 정확히 모르겠네요...
저는 인터페이스가 객체 간에 상호작용을 할 수 있도록 어떤 메세지를 전달할 지 정해진 객체( -> 프로토콜)라고 생각합니다.
인터페이스 내 대부분의 구현은 은닉화해놓고, 이를 사용할 수 있도록 캡슐화되어 있는 메서드만 노출시키는 것이 좋지 않을까 생각이 됩니다! |
위에서 지성이 적어주신 브릿지 패턴을 swift에 적용하면 간접참조에 해당하지 않을까 추측되네요.
|
|
|
인터페이스는 상호작용할 수 있는 창구라고 이해했습니다. 책의 164p의 다른 객체가 다른 객체에게 접근하고 요청할 수 있는 방법은 메서드와 프로퍼티를 통해서뿐인 것 같다고 생각했습니다. 제가 생각해본 인터페이스와 구현을 분리하는 방법으론
이 있다고 생각했습니다. |
The text was updated successfully, but these errors were encountered: