Hi,
I'm searching for a good pattern for the following problem:
In a large object tree, all object implement a property called IsDirty.
That flag is set when a property is modified. If a child object is
dirty, the parent object must return IsDirty = true as well. This works.
I now want to have an event on the root object of the tree, that signals
when one object in the tree is set to dirty. What is a good approach for
this?
All i can come up with is a brute fore approach where i get a list of
all the objects in the tree, and subscribe to an event of each object
called something like "DirtyStateChanged".
Ward 5 5020
Hi,
It depends on how quickly you are required to determine the dirty state. You
can act proactively as you have described, so you spend CPU cycles on
handling the events, but you have the answer ready in no time. Or, when the
IsDirty property is queried on the root object, just do a recursive walk on
the object graph and if at least one of the child objects is dirty, the
entire graph is dirty.
--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]
"wbekker" <w.bekker@REMOVEequanimityTHISdotnl> wrote in message
news:42***********************@news.xs4all.nl... Hi,
I'm searching for a good pattern for the following problem:
In a large object tree, all object implement a property called IsDirty. That flag is set when a property is modified. If a child object is dirty, the parent object must return IsDirty = true as well. This works.
I now want to have an event on the root object of the tree, that signals when one object in the tree is set to dirty. What is a good approach for this?
All i can come up with is a brute fore approach where i get a list of all the objects in the tree, and subscribe to an event of each object called something like "DirtyStateChanged".
Ward
"wbekker" <w.bekker@REMOVEequanimityTHISdotnl> wrote in message
news:42***********************@news.xs4all.nl... Hi,
I'm searching for a good pattern for the following problem:
In a large object tree, all object implement a property called IsDirty. That flag is set when a property is modified. If a child object is dirty, the parent object must return IsDirty = true as well. This works.
I now want to have an event on the root object of the tree, that signals when one object in the tree is set to dirty. What is a good approach for this?
All i can come up with is a brute fore approach where i get a list of all the objects in the tree, and subscribe to an event of each object called something like "DirtyStateChanged".
Ward
I had a similar problem when creating a menu for a website.
I solved it by having the nodes be parent-aware and have IsDirty bubble up.
Hence, a leaf could make an entire branch dirty.
But while we're at it. I would rename IsDirty to an protected member called
invalidated. And sport the method Invalidate(). Guess I'm too fond of
Delphi.
- Michael S
wbekker <w.bekker@REMOVEequanimityTHISdotnl> wrote in news:42b66045$0$21663
$e*******@news.xs4all.nl: All i can come up with is a brute fore approach where i get a list of all the objects in the tree, and subscribe to an event of each object called something like "DirtyStateChanged".
If you have an ownership/parentage relationship the child objects could also call directly into the
parent instead.
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"
Get your ASP.NET in gear with IntraWeb! http://www.atozed.com/IntraWeb/
As a number of people here have stated, you're probably better off walking
up the parent hierarchy. You are accomplishing essentially the same thing
as the event subscription, but this way, you don't have to use events.
Remember: each event subscription is a new object allocation -- the
delegate. And that delegate essentially goes into a collection (the events
are multicast -- they don't look like collections, but you are holding on to
each delegate)
"wbekker" <w.bekker@REMOVEequanimityTHISdotnl> wrote in message
news:42***********************@news.xs4all.nl... Hi,
I'm searching for a good pattern for the following problem:
In a large object tree, all object implement a property called IsDirty. That flag is set when a property is modified. If a child object is dirty, the parent object must return IsDirty = true as well. This works.
I now want to have an event on the root object of the tree, that signals when one object in the tree is set to dirty. What is a good approach for this?
All i can come up with is a brute fore approach where i get a list of all the objects in the tree, and subscribe to an event of each object called something like "DirtyStateChanged".
Ward
Thank you all for the great suggestions, i will give the "walking up the
parent hierarchy" a try!
Ward
J.Marsch wrote: As a number of people here have stated, you're probably better off walking up the parent hierarchy. You are accomplishing essentially the same thing as the event subscription, but this way, you don't have to use events.
Remember: each event subscription is a new object allocation -- the delegate. And that delegate essentially goes into a collection (the events are multicast -- they don't look like collections, but you are holding on to each delegate)
"wbekker" <w.bekker@REMOVEequanimityTHISdotnl> wrote in message news:42***********************@news.xs4all.nl...
Hi,
I'm searching for a good pattern for the following problem:
In a large object tree, all object implement a property called IsDirty. That flag is set when a property is modified. If a child object is dirty, the parent object must return IsDirty = true as well. This works.
I now want to have an event on the root object of the tree, that signals when one object in the tree is set to dirty. What is a good approach for this?
All i can come up with is a brute fore approach where i get a list of all the objects in the tree, and subscribe to an event of each object called something like "DirtyStateChanged".
Ward This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Andy Read |
last post by:
Hello all,
I have the requirement to produce source code that produces an object
hierarchy.
Example:
Root
|
Folder 1
|
by: BlueMonkMN |
last post by:
I've been trying to think of the right way to design relationships
between objects with different desired lifetimes that raise events.
If an event source is a relatively permanent object and the...
|
by: Mary |
last post by:
Is there a good document online on how to implement IsDirty for Winforms? I
am having on how to design for IsDirty. My forms have alot of controls that
the user will need to input before the user...
|
by: fperfect13 |
last post by:
The problem is like this:
I have a class C1 which has a private field "private Graph graph;"
accesed by a property(C1.Graph). The class Graph is serializable but
when i pass to a method that...
|
by: Codemonkey |
last post by:
Heya All,
Sorry, but I think it's about time for a monkey-ramble.
I've just had enough of trying to serialize even simple objects with VB. A
simple task you may think - stick the...
|
by: Charles Law |
last post by:
Mr "yEaH rIgHt" posted the following link about a week ago in answer to my
question about removing event handlers.
> http://www.vbinfozine.com/t_bindevt.shtml
Following on from that post, the...
|
by: halekio |
last post by:
Hi all,
Please bear with me as I've only started programming in C# 2 weeks ago
and this is my first contact with OOP.
I ran into a situation where I needed to catch an event in an object
that...
|
by: halekio |
last post by:
Hi all,
Please bear with me as I've only started programming in C# 2 weeks ago
and this is my first contact with OOP.
I ran into a situation where I needed to catch an event in an object
that...
|
by: =?Utf-8?B?U3dhcHB5?= |
last post by:
Can anyone suggest me to pass more parameters other than two parameter for
events like the following?
Event:
Onbutton_click(object sender, EventArgs e)"
Event handler:
button.Click += new...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |