473,725 Members | 2,180 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 1732

"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
5749
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
4619
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 the Escape key to cancel changes to new or existing records. On existing records, Access already...
10
17213
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, which isn't useful at all. So even if I want to write my own Set implementation, what interface...
1
4549
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
2504
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 I've written just fine. This one is more
9
3101
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 instance of the class and now it shows up all okay in the Intellisense. Whenever I try to run a simple...
0
2215
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
2199
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 the \bin folder. Can anyone tell me what I'm doing wrong or what I should check? TIA. Server...
0
8752
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9257
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9176
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9113
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8097
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6702
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6011
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3221
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

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.