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 8199749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:14:07+00:00 2026-06-07T06:14:07+00:00

I have this situation: An object that it’s observable and another object that it

  • 0

I have this situation:

An object that it’s observable and another object that it is observer.

the observer has a method update(Observable obs,Object obj) that receive through notifyObservers the object changed.when observer receives the notify, update method prints the object changed. I want print out the result in a gui that implements MVC pattern.I’m following this guide MVC pattern.
My idea is to make the Controller the observer. something like that:

public class Controller extends AbstractController implements Observer 
{
    public static final String TOTAL_HIT_COUNT_PROPERTY = "Total Hit";

    public void changeTotalHitCount(long new_total_hit_count)
    {
        setModelProperty(TOTAL_HIT_COUNT_PROPERTY, new_total_hit_count);
    }

    @Override
    public void update(Observable o, Object arg) 
    {

    }
}

but I don’t know if it’s a correct implementation!

  • 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-07T06:14:08+00:00Added an answer on June 7, 2026 at 6:14 am

    Observer Pattern and MVC Pattern are 2 distinct design pattern – just to make sure we are on the same page.

    In the MVC (at least by definition) pattern, the View is supposedly automatically updated when the Model changes, I am guessing this is what you are trying to do. In that situation, that means your Observer should be the View, not the Controller, and your Model will be your Observable object.

    Thus:

    Observable changes --> update Observer
    

    will sort of replicate what you are trying to get in the pure MVC pattern:

    Model changes --> update View
    

    I am not saying this should be the way to do things, but I would think if you try to apply the Java’s Observer/Observable to the MVC pattern, this could be on way to go with.

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

Sidebar

Related Questions

How to write right in this situation: I have some method, that return NSMutableArray*.
The situation is this: You have a Hibernate context with an object graph that
I have a class that has a new method and uses that object to
I have a method that returns a CGImageRef object. It contains this call: CGImageRef
I ran into this situation today. I have an object which I'm testing for
I have this situation object SuperHorribleLongName { trait X { private[SuperHorribleLongName] def internalGaga() :
Just wondering whether an object can self-destruct. Consider this situation. An object that extends
Just wondering whether an object can self-destruct. Consider this situation. An object that extends
I have one complicated situation with JavaScript. I have created object. This object loads
I have a function to sort a JSON object that looks like this: function

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.