Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Object communication in java?

 
Ashish K Sharma
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I want to Notify an class A whenever something happenes to another class B, i mean any method called, any variable updated?
How can i achieve this in java?

Ashish
 
Awais Bajwa
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use a referece of Clas A to get notified in B. Read Observer Design Pattern.
Awias Bajwa
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you change class B?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to Notify an class A whenever something happenes to another class B,


Keep in mind that you are really talking about an instance of class A and an instance of class B, NOT the Class object.

Bill
 
Ashish K Sharma
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your inputs.
Yes it's abour object instances for sure.
I believe i need to gain more knowledge on design patterns first.
Thanks again
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic