<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Observer on Java &amp; Software Architecture Knowledge Hub</title><link>https://samirsahoo.github.io/design-patterns-hub/tags/observer/</link><description>Recent content in Observer on Java &amp; Software Architecture Knowledge Hub</description><generator>Hugo</generator><language>en-US</language><copyright>© 2026 Samir Kumar Sahoo (https://github.com/samirsahoo). All rights reserved.</copyright><atom:link href="https://samirsahoo.github.io/design-patterns-hub/tags/observer/index.xml" rel="self" type="application/rss+xml"/><item><title>Observer vs Mediator vs Event Bus</title><link>https://samirsahoo.github.io/design-patterns-hub/comparisons/observer-mediator-event-bus/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://samirsahoo.github.io/design-patterns-hub/comparisons/observer-mediator-event-bus/</guid><description>&lt;h2 id="the-short-answer"&gt;The short answer&lt;a class="heading-anchor" href="#the-short-answer" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;div class="table-wrap" tabindex="0" role="region" aria-label="Table"&gt;&#10;&lt;table&gt;&#10; &lt;thead&gt;&#10; &lt;tr&gt;&#10; &lt;th&gt;&lt;/th&gt;&#10; &lt;th&gt;&lt;a href="https://samirsahoo.github.io/design-patterns-hub/design-patterns/behavioral/observer/"&gt;Observer&lt;/a&gt;&lt;/th&gt;&#10; &lt;th&gt;&lt;a href="https://samirsahoo.github.io/design-patterns-hub/design-patterns/behavioral/mediator/"&gt;Mediator&lt;/a&gt;&lt;/th&gt;&#10; &lt;th&gt;Event bus (publish/subscribe)&lt;/th&gt;&#10; &lt;/tr&gt;&#10; &lt;/thead&gt;&#10; &lt;tbody&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;Who knows whom&lt;/td&gt;&#10; &lt;td&gt;Subject knows its observers (through an interface)&lt;/td&gt;&#10; &lt;td&gt;Colleagues know the mediator; mediator knows colleagues&lt;/td&gt;&#10; &lt;td&gt;Publishers and subscribers know only the bus and event types&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;Where the logic is&lt;/td&gt;&#10; &lt;td&gt;Each observer decides how to react&lt;/td&gt;&#10; &lt;td&gt;&lt;strong&gt;Centralised&lt;/strong&gt; in the mediator&lt;/td&gt;&#10; &lt;td&gt;Each subscriber decides; nobody coordinates&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;Direction&lt;/td&gt;&#10; &lt;td&gt;One-to-many broadcast&lt;/td&gt;&#10; &lt;td&gt;Many-to-one-to-many, two-way&lt;/td&gt;&#10; &lt;td&gt;Many-to-many broadcast&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;Control flow&lt;/td&gt;&#10; &lt;td&gt;Easy to find: look at the subject&amp;rsquo;s observers&lt;/td&gt;&#10; &lt;td&gt;Easy to find: read the mediator&lt;/td&gt;&#10; &lt;td&gt;Hard to find: search for subscribers of an event type&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;Typical scope&lt;/td&gt;&#10; &lt;td&gt;One object and its dependents&lt;/td&gt;&#10; &lt;td&gt;One dialog, workflow or interaction&lt;/td&gt;&#10; &lt;td&gt;A whole application, or many services via a broker&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;p&gt;The deciding questions:&lt;/p&gt;</description></item><item><title>Spring Application Events and Listeners</title><link>https://samirsahoo.github.io/design-patterns-hub/spring/core/application-events/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://samirsahoo.github.io/design-patterns-hub/spring/core/application-events/</guid><description>&lt;h2 id="simple-definition"&gt;Simple definition&lt;a class="heading-anchor" href="#simple-definition" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;Spring&amp;rsquo;s &lt;strong&gt;application events&lt;/strong&gt; let one bean &lt;strong&gt;publish&lt;/strong&gt; a message (&amp;ldquo;an order was placed&amp;rdquo;) and any number of other beans &lt;strong&gt;listen&lt;/strong&gt; and react, without the publisher knowing them. It is the Observer pattern, implemented by the &lt;code&gt;ApplicationContext&lt;/code&gt;, &lt;strong&gt;inside one application&lt;/strong&gt;.&lt;/p&gt;</description></item><item><title>Observer Pattern</title><link>https://samirsahoo.github.io/design-patterns-hub/design-patterns/behavioral/observer/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://samirsahoo.github.io/design-patterns-hub/design-patterns/behavioral/observer/</guid><description>&lt;h2 id="simple-definition"&gt;Simple definition&lt;a class="heading-anchor" href="#simple-definition" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;The &lt;strong&gt;Observer&lt;/strong&gt; pattern lets an object (the &lt;strong&gt;subject&lt;/strong&gt;) keep a list of interested objects (&lt;strong&gt;observers&lt;/strong&gt;) and notify all of them automatically when something happens. The subject knows only that observers implement a small interface; it does not know what they do.&lt;/p&gt;</description></item><item><title>Compound Patterns: How MVC Combines Observer, Strategy and Composite</title><link>https://samirsahoo.github.io/design-patterns-hub/design-patterns/compound-patterns-mvc/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://samirsahoo.github.io/design-patterns-hub/design-patterns/compound-patterns-mvc/</guid><description>&lt;h2 id="simple-definition"&gt;Simple definition&lt;a class="heading-anchor" href="#simple-definition" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;A &lt;strong&gt;compound pattern&lt;/strong&gt; is a set of patterns that work together to solve a recurring, larger problem. The best-known is &lt;strong&gt;Model-View-Controller (MVC)&lt;/strong&gt;, which &lt;em&gt;Head First Design Patterns&lt;/em&gt; calls &amp;ldquo;the king of compound patterns&amp;rdquo;. It is built from three GoF patterns:&lt;/p&gt;</description></item></channel></rss>