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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:34:32+00:00 2026-05-24T05:34:32+00:00

I used the template pattern for an algorithm I’m writing. But I combined it

  • 0

I used the template pattern for an algorithm I’m writing. But I combined it with the observer pattern to get informed about the process.

public abstract class Test extends Observable

In the method for the algorithm i call the notify

public final void findSolution() {
 // run algorithm
 notifyObservers();
}

This abstract class with the findSolution method will be extended by different algorithm implementations. The UI just keeps a reference to the Test and calls the findSolution() but the update method from the ui will never be invoked does anybody now what is wrong?

public class CreateViewResults implements Observer {
 private Test algorithm;

 public CreateViewResults() {
  algorithm = new OneTestImpl();
  algorithm.addObserver(this);
  algorithm.findSolution();
 }

 @Override
 public update( Observable ob, Object o ) {
  System.out.println("Update");
 }

}
  • 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-05-24T05:34:33+00:00Added an answer on May 24, 2026 at 5:34 am

    Nothing happens because the observable hasn’t changed.

    From the javadoc:

    If this object has changed, as indicated by the hasChanged method,
    then notify all of its observers and then call the clearChanged method
    to indicate that this object has no longer changed.

    You should thus call setChanged() before notifying the observers.

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

Sidebar

Related Questions

Template code is not compiled until the template function is used. But where does
I am trying to add a new project template for an often used pattern.
I'm in the process of writing a template library for data-caching in C++ where
In the Java Desktop Application template used by Netbeans, a menu bar is created
I have used the following template in my project: <DataTemplate x:Key=textBoxDataTemplate> <TextBox Name=textBox ToolTip={Binding
I'm maintaining the Perl Beginners' Site and used a modified template from Open Source
I've used the Views Theming Wizard to output a template and it gave me
When declaring a template, I am used to having this kind of code: template
I'm trying to replicate a template I've used before with a member function, and
If I have a template as follows, which is used to create a button:

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.