473,549 Members | 2,829 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Catching "set" operations for exposed reference types (enlist for processing in transaction)

Hello!

I was looking at marking objects with a changed state, once properties have
been changed. The reason behind this is, that I would like to enlist such
objects for processing in a transaction.

The example below illustrates a sample pattern, which is fine when exposing
simple value types.

However, when exposing reference types, it becomes really hard (if not
impossible) to determine if changes to the state of the original object are
made. I have been looking at the implementation details of .NET framework
classes such DataColumn etc., but those only expose value types.

My fealing is that, unless the exposed reference exposes "change" events,
you are blind to any calls (hence potential changes) made to that reference.

I see several answers of catching "set" operations/marking state:

1. Custom Attributes (means calling messages through sinks; slows
performance significantly; inherit from MarshalByRefObj ect)

2. If using reference types, only use types with "change" events such as
XmlDocument (or your own custom reference types).

3. Don't use reference types - provide developers with parser classes and
ask them to "set" the parsed value as value type back to the original
object.

4. An explicit call to a CmsObject.Enlis t() method, that asks the developer
to manually enlist the object for processing. This might look like a good
design, but it asks the developer to remember calling the method (and adds
to the number of code lines - I could provide both: AutoEnlist and manual
using .Enlist())..

5. Your suggestion?

class CmsObject
{
private string _name;
private NodeState _state = NodeState.Uncha nged;

public string Name
{
get { return this._name; }
set
{
this._name = value;
this.OnChange() ;
}
}

private void OnChange()
{
this._state = NodeState.Chang ed;
}
}

This exercise is mostly for fun; I've been thinking about this for quite
some time and we've had some great discussions on how to implement this with
the current options in .NET (also compared it to other programming
environments).

I am looking for comments on patterns and suggestions, as some of you
hopefully have been doing things like this lots of times :-)

--
Venlig hilsen
Anders Borum / SphereWorks
Microsoft Certified Professional (.NET MCP)

Feb 7 '06 #1
2 1722

"Anders Borum" <an****@spherew orks.dk> wrote in message
news:%2******** ************@TK 2MSFTNGP12.phx. gbl...
Hello!

I was looking at marking objects with a changed state, once properties
have been changed. The reason behind this is, that I would like to enlist
such objects for processing in a transaction.
I would suggest a IChanged interface , it should be easier later to treat
different types in the same way.

However, when exposing reference types, it becomes really hard (if not
impossible) to determine if changes to the state of the original object
are made. I have been looking at the implementation details of .NET
framework classes such DataColumn etc., but those only expose value types.

You are right it's not possible, not without the colaboration of the
referenced type (if it does implement IChanged is easier )
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Feb 7 '06 #2
Hello!
I would suggest a IChanged interface , it should be easier later to treat
different types in the same way.
I am already providing the relevant "change" members in a shared baseclass
that all "changeable " classes implement.
You are right it's not possible, not without the colaboration of the
referenced type (if it does implement IChanged is easier )


I am also doing this already, but was wondering if I had missed something.

Thanks for the suggestions Ignacio!

--
Venlig hilsen
Anders Borum / SphereWorks
Microsoft Certified Professional (.NET MCP)
Feb 7 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
5726
by: Me | last post by:
Hi, I would like learn from people with experience in C++, which of the following styles of way to construct "get/set" member functions would be the best in terms of usability, speed, et cetera. The following class with be used as an example: class MyClass { public: // member function would go here. private: int data_;
3
4598
by: Paul | last post by:
I have an Access 2000 database with a form that is giving me some major headaches. When you open the form, it displays all records and allows editing, but has AllowAdditions set to False so that the user has to use my New Record button. When you click the New Record button, the form presents a new record for editing. My client wants to use...
10
17190
by: Mart | last post by:
What class does everyone out there use if they want to store a set of values efficiently? In java I use a HashSet, but there is no equivalent in C#. Even worse, the lowest level interface to define the Add, Contains and Remove methods is an IList, and we all should know that a set isn't a list. ICollection only defines Count and CopyTo,...
1
4544
by: bill salkin | last post by:
How can I implement set operations in VB.NET. For example, {1,2,3,4} union {3,4,5,6} = {1,2,3,4,5,6} {1,2,3,4} minus {0,3} = {1,2,4} {1,2,3,4,5,6,7} intersect {0,2,7} = {2,7} Bill
1
2497
by: DaveO. | last post by:
Hello, I'm calling a VB.NET web service, also from VB.NET, and I get the error " Object reference not set to an instance of an object" on the following line in Reference.vb, when it tries to make the call: Dim results() As Object = Me.Invoke("Phys_Post", New Object() {SessionID, a, b, c, d, CountList}) I can call other web services...
9
3078
by: axs221 | last post by:
I am trying to move some of our large VBA Access front-end file into ActiveX DLL files. I created two DLL files so far, one was a module that contains code to integrate into the QuickBooks accounting software. Another has general utilities. I tried referencing the utilities dll, and it shows up in the object explorer. I instantiated an...
0
2204
by: =?Utf-8?B?SkhhbGV5?= | last post by:
Our system is: IIS Server: dual Intel Xeon 2.80 GHz, 4 GB Ram Windows Server 2003 SP2 IIS 6.0 SQL Server: dual Intel Xeon 2.80 GHz, 4 GB Ram (separate server) Windows Server 2003 SP2 SQL Server 2000 We are having some problems with a website we are developing, and had some
2
2178
by: Monty | last post by:
I'm installing an ASP.Net 2.0 web applications project (WAP) application on a production server (Win 2003). I've installed it on XP test machines before and it runs fine. On my production machine I get this error (full error screen below) when I attempt to visit the start page. The type ("MyCo.Ing.MyAppRoleProvider") is in my main assembly in...
0
7480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7992
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7840
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6088
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5396
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3525
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3509
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1973
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1087
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.