Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Another Cheezy Tip of the Week (VFP6)
Message
 
À
14/07/1998 16:57:07
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00116665
Message ID:
00117369
Vues:
16
Hi Dragan,

>What's the difference, in this case? The forms should be (instances or subclassed instances) of the same class, so they could have the same EditState_assign routine, right? So, the code handling this event is stored only once; therefore having an Observer is almost superfluous, _unless_ it's doing some other things too.

You are right. Both the methods are going to work. Though, what by having another object which overlooks is more flexible because, I can then register just my second page and it would work without any problems. Moreover, it would be more easy to reuse it for e.g. use in another project which uses a different framework for developement.

>Now what's the list of good uses for an Observer, and what's the difference if the observing is done by an application object? I think I remember months ago there were some threads here, where several good solutions on form handling (multiple instances of the same form and other issues) were said are handled best by an app object; now it's the Observer (instead or along with it?).

No. The app object totally different. Though it would a good place which could hold this Observer or others.

>Since the concept of Observer is relatively new, I think we'd need some clarification of the whole idea.
An observer usually defines a 1-many dependency between objects, so when one object changes its state, it notifies the observer and the observer updates the dependent objects(Push Model). There can be observers which find out themselves when the data is changed and update the dependent objects (Pull model e.g. Ken Levy’s SuperCls utility). YAG wrote an article in FoxPro Advisor regarding this design pattern and Steve Black has some nice examples in in design pattern articles on the UT (look in 1997). Moreover, there is a book, Design Patterns, by Erich-Richard-Raplh-John (Gang of Four) which is excellent and is a good read for any developer who designs classes.

In this particular example of John, I would actually be exploiting the observer by usuing it as an interface handler rather than as a Synchronizer.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform