HI guys, as I was playing with observers today I came across something interesting. I have a program which keeps a list of users (Observers) and products (Observables) and the idea is that whenever the availability (that's a property of a product) changes the Observers are notified of this change. It all worked OK when there was 1 product with multiple users but now that I have multiple products things are falling apart and it seems I'm causing a memory leak somewhere - probably due to the fact thtat I'm not fully understanding the Observer pattern. So when I try …

Member Avatar
Member Avatar
+0 forum 5

hi guys, I've come across observers while working ona very very large project, and I didn't quite understand how they were structured and I suppose this had something to do with the huge size of the project itself. Anyway, I then decided to delve a little more into that, I had a look in a few places, believe I understand more or less the theory and wrote some code - well in fact it's code that I got from a few places, play with it a little bit and then pretty much re wrote it again.. So, to my question …

Member Avatar
Member Avatar
+0 forum 3

Hi, I'm working on my assignment there are two parts of the assignment first part was to create class (ClassOne,ClassTwo,ClassThree,ClassFour,ClassFive) ClassFive extends ClassTwo and ClassTwo is abstract the secod part is to add the iobserver and iSubject , but I don't know how to implemet this part in the UML diagram it show that ClassOne is connected to iObserver and iSubject ClassThree is connected to iObserver ClassFour is connected to iObserver and iSubject ClassFive is connected to iObserver and iSubject the arrows are dotted can you explain to me which class extend and implements iObserve and iSubject and how can …

Member Avatar
Member Avatar
+0 forum 2

Hi I have a scenario that i need to implement. the scenario is below. I have a class handler and a class Healthmonitor. every 10 seconds i have to send a msg to HealthMonitor to update a variable. in one point if it didnt send a msg in a multiple of 10 seconds HealthMonitor DO SOMETHING ELSE How do i implement this. can someone give an idea to achieve this appreciate it thanks

Member Avatar
Member Avatar
+0 forum 5

The problem with my code is that the update method doesn't get invoked even after I notify the observers. Did I miss something in my code? package com.observer3; import java.awt.FlowLayout; import java.util.Observable; import java.util.Observer; import javax.swing.JLabel; import javax.swing.JPanel; public class A extends JPanel implements Observer{ JLabel lbl; public A(){ setLayout(new FlowLayout()); lbl = new JLabel(""); add(lbl); } public void update(Observable o, Object arg) { C c = (C)o; lbl.setText(Integer.toString(c.getCount())); } } package com.observer3; import java.awt.FlowLayout; import java.util.Observable; import java.util.Observer; import javax.swing.JLabel; import javax.swing.JPanel; public class B extends JPanel implements Observer{ JLabel lbl; public B(){ setLayout(new FlowLayout()); lbl = new JLabel(""); …

Member Avatar
Member Avatar
+0 forum 4

HI Part 1: I have 4 classes Handler, ResultE, QueryE and the HealthMonitor. The Handler, ResultE, QueryE classes have to send a message every 1 min (for example, the time is defined in each class) to the HealthMonitor. So i implemented the Observer patter. The Handler, ResultE, QueryE as Subjects and the HealthMonitor as the Observer. part 2: as in the example every 1 min the Handler, ResultE and the QueryE has to notify the status(the status of the current instance) to the HealthMonitor. if there is not notification from the handler the healthMonitor calls the Proxy and initiates the …

Member Avatar
Member Avatar
+0 forum 3

HI, how do i draw the observer pattern in a component diagram? appreciate if someone could point me to a link thanks,

Member Avatar
Member Avatar
-1 forum 1

Hello, I have a observer pattern based JTable. With time it is poulated with new data packets. I use addRow functionalities to add my rows. But I want to put always the last coming datapackets at the top. How to do it??

Member Avatar
+0 forum 0

Hi there, I have been studying he Observer pattern among other design patterns, and I am having difficulty understanding how it works. I have read the design patterns book by Head First where applicable and researched it like crazy on the internet. I was wondering if anyone can point out the different varaitions of the Observer pattern and maybe show a simple example of how it actually works? I understand the pattern at a UML level, but I cannot write code that gets it to work. I have an integer that can can change value and I have an Abstract …

Member Avatar
+0 forum 0

The End.