Re:To datamodule or to not datamodule
Another solution is to use the Observer pattern. Using a TList isntance in
the datamodule, you can attach and detach observers to the datamodule. When
a particular state changes on any component that needs to notify the
observers of the change, run through the list and call a custom notification
event implemented in the observer class.
For more information, refer to the book "Design Patterns" by Erich Gamma,
Richard Helm, Ralph Johnson, and John Vlissides (published by
Addison-Wesley). Here is a site where you can find the information in
electronic format...
http://sern.ucalgary.ca/courses/SENG/609.04/W98/lamsh/observerLib.html
Scott
Quote
"Richard Bibby" <richard.bi...@wilnor.se> wrote in message
news:3ee20e67$1@newsgroups.borland.com...
Quote
> Hello,
> After many years of not using datamodules have started to use them in my
> last few app. Afterall it makes sense to put your data model into one
unit,
> and handle all the consistency checks and errors there.
> But i keep coming up against the problems of reflecting dataset state in
my
> forms. For instance if the dataset is empty maybe i disable a few
> buttons... or when inserting i have to change a few menu items...
> So i use to link all this code to the events of the dataset i.e.
> OnNewRecord, OnChangeState etc... BUT now i find that i must put this
code
> in my Data Module... and here i only want to have put data related code
and
> nothing to do with my forms.
> If i move the datasources to my forms unit then I end up having trouble
> using master datail relationships because then i have to "use" the form
unit
> in the data module so i can link the datasets.
> Is there a better way of doing all this?
> /Richard