Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8307369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:30:43+00:00 2026-06-08T18:30:43+00:00

I’ve noticed that my dependency injected, observer-pattern-heavy code (using Guava’s EventBus ) is often

  • 0

I’ve noticed that my dependency injected, observer-pattern-heavy code (using Guava’s EventBus) is often significantly more difficult to debug than code I’ve written in the past without these features. Particularly when trying to determine when and why observer code is being called.

Martin Oderski and friends wrote a lengthy paper with an especially alluring title, "Deprecating the Observer Pattern" and I have not yet made the time to read it.

I’d like to know what is so wrong with the observer pattern and so much better about the (proposed or other) alternatives to lead such bright people to write this paper.

As a start, I did find one (entertaining) critique of the paper here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T18:30:44+00:00Added an answer on June 8, 2026 at 6:30 pm

    Quoting directly from the paper:

    To illustrate the precise problems of the observer pattern,
    we start with a simple and ubiquitous example: mouse dragging.
    The following example traces the movements of the
    mouse during a drag operation in a Path object and displays
    it on the screen. To keep things simple, we use Scala closures
    as observers.

    var path: Path = null
    val moveObserver = { (event: MouseEvent) =>
       path.lineTo(event.position)
       draw(path)
    }
    control.addMouseDownObserver { event =>
       path = new Path(event.position)
       control.addMouseMoveObserver(moveObserver)
    }
    control.addMouseUpObserver { event =>
       control.removeMouseMoveObserver(moveObserver)
       path.close()
       draw(path)
    }
    

    The above example, and as we will argue the observer
    pattern as defined in [25] in general, violates an impressive
    line-up of important software engineering principles:

    Side-effects Observers promote side-effects. Since observers
    are stateless, we often need several of them to simulate
    a state machine as in the drag example. We have to save
    the state where it is accessible to all involved observers
    such as in the variable path above.

    Encapsulation As the state variable path escapes the scope
    of the observers, the observer pattern breaks encapsulation.

    Composability Multiple observers form a loose collection
    of objects that deal with a single concern (or multiple,
    see next point). Since multiple observers are installed at
    different points at different times, we can’t, for instance,
    easily dispose them altogether.

    Separation of concerns The above observers not only trace
    the mouse path but also call a drawing command, or
    more generally, include two different concerns in the
    same code location. It is often preferable to separate the
    concerns of constructing the path and displaying it, e.g.,
    as in the model-view-controller (MVC) [30] pattern.

    Scalablity We could achieve a separation of concerns in our
    example by creating a class for paths that itself publishes
    events when the path changes. Unfortunately, there is no
    guarantee for data consistency in the observer pattern.
    Let us suppose we would create another event publishing
    object that depends on changes in our original path, e.g.,
    a rectangle that represents the bounds of our path. Also
    consider an observer listening to changes in both the
    path and its bounds in order to draw a framed path. This
    observer would manually need to determine whether the
    bounds are already updated and, if not, defer the drawing
    operation. Otherwise the user could observe a frame on
    the screen that has the wrong size (a glitch).

    Uniformity Different methods to install different observers
    decrease code uniformity.

    Abstraction There is a low level of abstraction in the example.
    It relies on a heavyweight interface of a control
    class that provides more than just specific methods to install
    mouse event observers. Therefore, we cannot abstract
    over the precise event sources. For instance, we
    could let the user abort a drag operation by hitting the escape
    key or use a different pointer device such as a touch
    screen or graphics tablet.

    Resource management An observer’s life-time needs to be
    managed by clients. Because of performance reasons,
    we want to observe mouse move events only during a
    drag operation. Therefore, we need to explicitly install
    and uninstall the mouse move observer and we need to
    remember the point of installation (control above).

    Semantic distance Ultimately, the example is hard to understand
    because the control flow is inverted which results
    in too much boilerplate code that increases the semantic
    distance between the programmers intention and
    the actual code.

    [25] E. Gamma, R. Helm, R. Johnson, and J. Vlissides. Design
    patterns: elements of reusable object-oriented software.
    Addison-Wesley Longman Publishing Co., Inc., Boston, MA,
    USA, 1995. ISBN 0-201-63361-2.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
In my XML file chapters tag has more chapter tag.i need to display chapters

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.