SlideShare a Scribd company logo
1 of 11
Mediator Pattern
중재자패턴에 대해 알아보자!!
발표자 : 김기섭
What is
Mediator
Pattern?
• 중재자 패턴(mediator pattern), 조정자
패턴은 소프트웨어 공학에서 어떻게 객
체들의 집합이 상호작용하는지를 함축
해놓은 객체를 정의한다. 이 패턴은 프
로그램의 실행 행위를 변경할 수 있기
때문에 행위 패턴으로 간주된다.
• 중재자 패턴을 사용하면 객체 간 통신
은 중재자 객체 안에 함축된다. 객체들
은 더 이상 다른 객체와 서로 직접 통신
하지 않으며 대신 중재자를 통해 통신
한다. 이를 통해 통신 객체 간 의존성을
줄일 수 있으므로 결합도를 감소시킨다.
김기섭 강준수
김영희
김개똥
김철수
처음엔 분명
한명에 대한
정보만 알면
됐는데..
참여 인원이 늘어날수록,
점점 더 많은 커플링이 생
겨남
기존 구현의 문제
김기섭 강준수
김영희
김개똥
김철수
중재자
내가 다
처리해줄
게!
누가 새로 들
어오든 중개
자만 알면되
네!
중재자 패턴 사용
코드로 봅시다!
인터페이스
중재자는 유저를 추가,삭제, 메시
지 전송을 하는 역할을 한다.
인터페이스
Colleague들은 통신할 각각에 대해 알필
요없이 중재자만 알고 있으면 된다!
코드로 봅시다! 유저클래스 실제 구현
SendMessages와 ReceiveMessages를 구현
중재자를 통해 전달할 메시지를 입력한다!
이전에는 모두에게 메시지를 전달하려면 각각
에 대해 알고 하나하나 메시지를 전달해야했다.
ChatMediator는 모두가 통신할 수 있도록
User들의 정보를 저장할 List를 가지고, 추가,
삭제등의 기능을 구현한다.
그리고 메시지를 주고받을 수 있도록 기능
을 구현해준다.
코드로 봅시다!
이렇게 중개자를 만들고, 유저를 생성할 때, 중재자
에대한 정보를 넘긴다.
그리고 중재자는 채팅에 참여할 유저들을 추가한
다.
그리고 메시지를 각각에대해 모두 보낼필요없이
한번만 보내면 된다.
방에 입장할 때 중재자에게 등록만 해준다면
김기섭은 모든 친구들에게 메시지를 보낼 때 새
로 들어온 친구에 대해 몰라도 통신을 할 수 있
다.!
Mediator
Pattern
Advantages
• 장점
• 객체들간의 상호작용이 하나의 객체로
모아지기 때문에, 객체들이 서로를 직
접 참조하지 않게 되어 객체들이
loosely coupling 되는 효과가 있다!
• 객체들간의 상호작용 로직이 객체들과
분리되어 추상화되므로, 상호작용 로직
만을 쉽게 수정가능
• 런타임에 변경할 수 있다
• 각 객체들이 별도로 재사용이 가능해지
게 됩니다.
Mediator
Pattern
Disadvantages
단점
• Mediator 클래스 자체는 복잡도가 증가
해 유지보수가 어려워질 수 있음
중재자
으으.. 할게
너무많아..
A
너무 많은 일을 담당하면 God object가 될 수
있다.
뭐야.. 다
알잖아..
나!!
나!!
나!!
나!!
나!!
정리
• 중재자 패턴을 사용하면 복잡한 관계를 단순하게 만들 수 있다.
• 하지만 중재자가 하는 일이 너무 많아지면, 중재자 자체의 복잡
도가 증가하고, 통신자체가 복잡해지거나 객체의 형태가 자주
변경되는 경우 유지보수가 힘들다.
• 수고하셨습니다!!

More Related Content

Featured

How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellSaba Software
 
Introduction to C Programming Language
Introduction to C Programming LanguageIntroduction to C Programming Language
Introduction to C Programming LanguageSimplilearn
 

Featured (20)

How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
 
Introduction to C Programming Language
Introduction to C Programming LanguageIntroduction to C Programming Language
Introduction to C Programming Language
 

Mediator pattern

  • 1. Mediator Pattern 중재자패턴에 대해 알아보자!! 발표자 : 김기섭
  • 2. What is Mediator Pattern? • 중재자 패턴(mediator pattern), 조정자 패턴은 소프트웨어 공학에서 어떻게 객 체들의 집합이 상호작용하는지를 함축 해놓은 객체를 정의한다. 이 패턴은 프 로그램의 실행 행위를 변경할 수 있기 때문에 행위 패턴으로 간주된다. • 중재자 패턴을 사용하면 객체 간 통신 은 중재자 객체 안에 함축된다. 객체들 은 더 이상 다른 객체와 서로 직접 통신 하지 않으며 대신 중재자를 통해 통신 한다. 이를 통해 통신 객체 간 의존성을 줄일 수 있으므로 결합도를 감소시킨다.
  • 3. 김기섭 강준수 김영희 김개똥 김철수 처음엔 분명 한명에 대한 정보만 알면 됐는데.. 참여 인원이 늘어날수록, 점점 더 많은 커플링이 생 겨남 기존 구현의 문제
  • 4. 김기섭 강준수 김영희 김개똥 김철수 중재자 내가 다 처리해줄 게! 누가 새로 들 어오든 중개 자만 알면되 네! 중재자 패턴 사용
  • 5.
  • 6. 코드로 봅시다! 인터페이스 중재자는 유저를 추가,삭제, 메시 지 전송을 하는 역할을 한다. 인터페이스 Colleague들은 통신할 각각에 대해 알필 요없이 중재자만 알고 있으면 된다!
  • 7. 코드로 봅시다! 유저클래스 실제 구현 SendMessages와 ReceiveMessages를 구현 중재자를 통해 전달할 메시지를 입력한다! 이전에는 모두에게 메시지를 전달하려면 각각 에 대해 알고 하나하나 메시지를 전달해야했다. ChatMediator는 모두가 통신할 수 있도록 User들의 정보를 저장할 List를 가지고, 추가, 삭제등의 기능을 구현한다. 그리고 메시지를 주고받을 수 있도록 기능 을 구현해준다.
  • 8. 코드로 봅시다! 이렇게 중개자를 만들고, 유저를 생성할 때, 중재자 에대한 정보를 넘긴다. 그리고 중재자는 채팅에 참여할 유저들을 추가한 다. 그리고 메시지를 각각에대해 모두 보낼필요없이 한번만 보내면 된다. 방에 입장할 때 중재자에게 등록만 해준다면 김기섭은 모든 친구들에게 메시지를 보낼 때 새 로 들어온 친구에 대해 몰라도 통신을 할 수 있 다.!
  • 9. Mediator Pattern Advantages • 장점 • 객체들간의 상호작용이 하나의 객체로 모아지기 때문에, 객체들이 서로를 직 접 참조하지 않게 되어 객체들이 loosely coupling 되는 효과가 있다! • 객체들간의 상호작용 로직이 객체들과 분리되어 추상화되므로, 상호작용 로직 만을 쉽게 수정가능 • 런타임에 변경할 수 있다 • 각 객체들이 별도로 재사용이 가능해지 게 됩니다.
  • 10. Mediator Pattern Disadvantages 단점 • Mediator 클래스 자체는 복잡도가 증가 해 유지보수가 어려워질 수 있음 중재자 으으.. 할게 너무많아.. A 너무 많은 일을 담당하면 God object가 될 수 있다. 뭐야.. 다 알잖아.. 나!! 나!! 나!! 나!! 나!!
  • 11. 정리 • 중재자 패턴을 사용하면 복잡한 관계를 단순하게 만들 수 있다. • 하지만 중재자가 하는 일이 너무 많아지면, 중재자 자체의 복잡 도가 증가하고, 통신자체가 복잡해지거나 객체의 형태가 자주 변경되는 경우 유지보수가 힘들다. • 수고하셨습니다!!