• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Coomon Dialog frame in SCJD book

 
Tim Fernandez
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Andrew,

I'm just wondering if there is really a need to use the observer/observable patter when using a common dialog frame. Why do the server application and the client application need to be notified when a change in the common frame happens?

regards,
tim
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim,

The only reason we did this was so that the one dialog frame could be used in multiple applications or by multiple classes without the frame being aware of which classes might be connecting to it.

Regards, Andrew
 
Tim Fernandez
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Andrew Monkhouse:
Hi Tim,

The only reason we did this was so that the one dialog frame could be used in multiple applications or by multiple classes without the frame being aware of which classes might be connecting to it.

Regards, Andrew


Hi Andrew,

But we would still be able to implement the same without using the observable/design patter right?

regards,
tim
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim,

Yep, you can certainly do that.

Regards, Andrew
 
Tim Fernandez
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Andrew Monkhouse:
Hi Tim,

Yep, you can certainly do that.

Regards, Andrew



Hi Andrew,

But what are the pros/cons of using observable design here or not?

regards,
tim
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim,

Using the Observer pattern allows us to abstract the connection between the panel and the various applications that might be using it. Users of the panel do not need to know anything more about the panel other than it provides events through the update() method which it can then process.

A common alternative to this would be to expose the individual elements of the panel to the users of the panel (preferably through getters and setters). You would have to think about what you are exposing though - too many people expose the element itself (for example, a JTextField) rather than thinking about what the user is likely to want to access (the contents) and/or thinking about what exposing elements might do to later enhancability.

Regards, Andrew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic