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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:02:21+00:00 2026-06-14T14:02:21+00:00

I’m trying to make my app with PM design (MVC + Presentation Model), but

  • 0

I’m trying to make my app with PM design (MVC + Presentation Model), but I’ve already stuck on how to cleverly wrap Model classes in Presentation Model classes. Now, I write a simple code where a picture and a text are changed based on values in an instance of Model class.

// Disclaimer: 
// View and Controller are merged in this sample for clarity's sake. 

Enum

Enum AnimalSpecies {
    Dog, Cat, Rabbit, Bird,   
}

M of MVC + RM

class Model extends Observable {

    // in my actual code Model has 10+ member variables and most of them are Enum

    protected AnimalSpecies species;
    protected String name;
    protected Object update;

    public void setSpecies (AnimalSpecies species) {
        this.species = species;
        notifyUpdate(species); 
    }

    public void setName (String s) {
        this.name = s;
        notifyUpdate(name);
    } 

    public void notifyUpdate(Object o) {
        this.update = o;
        this.setChanged();
        this.notifyObservers(update);
    }
}

RM of MVC + RM

class PresentationModel extends Observable implements Observer {

@Override
    public void update(Observable model, Object data) {
        // Called when notified by Model

        // No idea what to write... but what I want to do is,  
        // a) determine what text for View to display
        // b) determine what pics for View to display, 
        // based on values of Model.    

        this.setChanged();
        this.notifyObservers(update);
    }    
}

VC of MVC + RM

class View extends Activity implements Observer {

    // This is View + Controller, so it'd implement some interfaces like onClickListener, 
    // and in events such as onClick(), values of Model class are changed, 
    // but for clarity's sake, I keep everything in onCreate() event. 

    TextView header;
    TextView footer
    ImageView imgview;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        header = (TextView) findViewById(R.id.header);
        footer = (TextView) findViewById(R.id.footer);
        imgview = (ImageView) findViewById(R.id.imgview);

        Model model = new Model();
        PresentationModel pm = new PresentationModel();
        model.addObserver(pm);
        pm.addObserver(this);

        model.setSpecies(AnimalSpecies.Cat);
        model.setName("Max");
    }

    @Override
    public void update(Observable pm, Object data) {

        // Called when notified by PresentationModel
        // *** varies based on parameters from PresentationModel

        header.setText(***);
        footer.setText(***);
        imgview.setImageResource(R.drawable.***);

    }

}

My question: how to write a logic in public void update() of class PresentationModel? I can get only an Object variable from NotifyObserver(), and even with nested switch or if … else, I can’t come up with codes at all…

  • 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-14T14:02:23+00:00Added an answer on June 14, 2026 at 2:02 pm

    Hmm, you probably want to tell your listeners what changed. For example, if the name field changed in the model, call notifyObservers(update, PROPERTY_NAME). Then the presentation model just needs logic to handle name changes.

    That said, I wouldn’t recommend using Presentation Model without a framework. There’s too much complexity and code required to fire events and move data around properly. Actually, even with a framework, there’s a significant learning curve – but I do think it’s a nice architecture for larger projects.

    JGoodies Binding is a good example of a Presentation Model framework. However, it’s targeted at Swing applications. It can be adapted for Android with some effort, but I would look to see if a good Android-specific framework exists.

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

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
this is what i have right now Drawing an RSS feed into the php,
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.