Hmmm. Not really sure about this one, but possibly the Observable pattern might help here. I'd really have to sit down with some paper to sketch it all out but basically you should be able to observe your rules (combine this with the Mediator pattern for best effect) and then notify the observer whenever a rule was being worked on or released from work.
Deja View - the feeling that you've seen this post before.
Hi Pete, Implementing pattern at this stage seems to be bit difficult since most of the functionalities are in place. This specific lock functionality wasn't there and introduced later stages. I presume, it would be nice to introduce some kind of wrapper or attribute in type level which ensure the object level isolation. However, my sincere thanks for your time. Please do update me in case if you sketch something.
You might use Single Proxy between multiple Users and Rule collection.
Let Proxy decide which user can access which rule object.
Or let there be one Proxy object for each of your Rule object.Each user instead of accesing rule object directly can access Proxy of that rule object and in Proxy you can decide whether to allow user to access the rule object or not.
It sounds like you are asking how to implement pessimistic locking. There are very simple ways of doing that, although most people agree that it is quite a user-unfriendly thing to do (but sometimes you have no choice).
Basically, create a mutex on the server for the particular rule being edited, and deny edit access to that rule for other users until the mutex is released. The mutex can be anything - for example MS Office products create a file when you open a document for editing, and delete it when you are done.
I have a large, and quite complicated model that i origionaly defined using an object hierachy, but the solution has out grown that.
I require an in memory model that raises events when it is changed. These events can then be handled by any observing controls which in turn can update themselves.
As the model is large, and each control is only interested in one particular part of the Model, i would like to be able to pull out a section of the XML document and observe and apply changes to this block. Idealy i would like to be able to pull an XmlDocument from another XmlDocument and use that, but keeping it synchronised with the parent document.
I am limited to the XmlDocument object due to a .Net 2.0 limitation, although the XDocument (And associated LINQ model) would be perfect for what i am trying to achieve as each node raises change events that bubble up the object hierachy.
Are there any other solutions anyone else can think of?
I don't think DataSets are appropriate to this problem. But i'm not sure what is. I've never encountered anything like this before so my approach may be wrong. I'll try to describe the application and my approach.
1) There is a hierachy of configurations, where a configuration represents a setup for physical goods. The hierachy represents their association.
2) Each configuration contains a block (Tree) of layout data for a visual designer, a block of Aggregates, and a number of other blocks representing various tertiary data tied to the configuration.
3) A number of different controls are bound to the blocks of data for a selected configuration, as well as a number of controls being bound to the hierachy of configuration (From point 1).
4) I am attempting to implement an MVC pattern, where the model would be the XML DOM, the view would be the various controls that are bound to the model, and the controller is the host form (for now) that handles events submitted from the various controls.
5) When the model is changed, i would like to update the views with the changes made. (This is my primary problem). I do not want to re-query the model completely and re-draw the UI when a block is changed, i am only interested in the actual changes made.
6) I require Undo / Redo functionality (Simple enough with an XML Document)
7) Not all displayed data is stored in the model. When the model changes an alternative data source is queried to load Images, Layout data and other values.
It makes me really appreciate how easy web development is when you just re-poll the model and draw a new page / widget.
If you could point me in the right direction with regards to an approach to this problem, it would be greatly appreciated. Alternatively design patterns that are relevant or strategies for solving any of the above issues individually would be just as good.
I don't think DataSets are appropriate to this problem.
If you think it is obvious from your post it's not, at least to me. I have implemented several .NET Desktop applications that use MVC with a DataSet at the core of the Model. In some cases the Data source is an XML file. However in most cases I started out thinking XML files would work and quickly moved on to using the SQL Desktop Database.
Our main .NET Desktop/Web application uses a Database with NHibernate and an Object Model. In my experience and listening to others on the internet talk about managing the session and data layers from a development standpoint, there is no silver bullet, period. You can't just drag and drop controls and handle events to generate a complete solution. If your project data has any level of complexity, and yours certainly does, you will have to do some development. Also IMHO Databases still rule when it comes to managing complex data relationships. If your project is large enough you might want to look into the Castle ActiveRecord implementation[^] which uses NHibernate.
Thanks for the input. I Can't explain why DataSets are not appropriate, as i'm not sure what concrete reasons i have. I just have a feeling that going down that route would produce bad results, and i've been stung by DataSets before.
In the end, i decided to go with a bog standard XML DOM, and build an API Class(s) that applies transformations, queries the data, and raises application specific events when the DOM changes. I'll just see how it goes.
Some friendly advice. Don't base your technical decisions on your feelings. Seriously, in todays world the availability of information eliminates the need to make blind decisions that were common years ago and resulted in the mountains of Technical Debt[^] that exist in the industry today.
Well, i'm trying to route all events through a single root object, only wiring up a hierachy of observable lists, trees and properties to do that will be an absolute nightmare as the model is growing almost daily.
Additionally, i need to be able to run XPath queries on any part of the model and define some kind of schema to validate against. Which i couldn't do with objects.
It's a desktop app if that makes any difference, and the XML would be the state of the solution and everything pretty much revolves around changing that and keeping display parts synchronized with it.