• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Observable patter in GUI

 
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi! I'm using the observable pattern for my GUI. I have created a own Interface for registrating Subjects and Publishers to communitate.

Problem is that in many times I have 15 classes both as a publisher and a Subscriber to oneanother.

This means that a ShapeManager can both be subscriber and publisher to a ColorPicker class.
This work in the beginning but know I'm have a cillion classes in at nest talking to each other. It's beginning to be unbareable to continue with this. How do you do this communication between guis?

Do you have a better ide then to do it like this?
 
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should use the mediator design pattern to coordinate all the Observers and Observables. In this way, they don't need to talk with each other, the publishers publish the message to the mediator. The subscribers subscribe the message they are interested.

Read GoF book for concepts and examples...

Thanks!
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Do you have a better ide then to do it like this?


What does your IDE have to do with fundamental design questions?
My big question is why are your ShapeManager (presumably a palate of shapes) talking to your ColorPicker (presumably a palate of colors)? Wouldn't you have some sort of work area (lets say a document) which would display the various shapes of various colors, and it would be the common listener for all the palates? Or wouldn't it be the individual widgets in the document itself that are created/effected by the various pallets?
In any case, when managing observable becomes overwhelming, it is time to consider taking that functionality out of your classes and using an event bus of some sort to manage messages between components.
 
Mathias Nilsson
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your responses. I know that the code has grown beond control and that the design is bad. I will consider your alternatives and do some reading.

Thanks
 
What are your superhero powers? Go ahead and try them on this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic