I have a question about ImageList strategies. Originally i created an image list for each control, but this didn't expand well, especially when i wanted the same icon in multiple locations. I made a few image lists that covered particular sets of icons as well, this seems to work well, but again suffers from cross cutting issues.
My thoughts for a solution would be to put two image lists in an IOC container and have the application setup the display components based on this. Is this viable?
How do other people manage application wide image lists in their apps? Also, what mechanisms do people put in place for managing Image Keys when the images are dynamic?
I was hoping someone may be able to give me some feedback on my design principles. I have done alot of applications relating to databases etc in c# but this is my first try at a Client / Server application. I wannted to check some of the recommended ways of performing client / server actions.
The application is basically a front end for a database.
Basically my program will consist of a server application which will have a connection to a database. When a client wants to see records from the database they send a request to the server, which in turn connects to the database, retrives the records ands sends the record data back across the network stream and the client parses the records and displays them. Does this sound like a standard and solid principle?
You are suggesting a forms application with 3 physical tiers (client, server, database)? That is appropriate if you want to scale to large amounts of clients, or if you have specific security concerns. Otherwise, you should be aware that it is more expensive to build than a simpler 2-tier arrangement.
(You should still logically split the application into layers).
This query is with respect to the isolation of object in a collection. And like to hear couple of approaches those are feasible in such scenario.
First, let me explain the problem which I am facing at this time. Our application has few rules (objects in concize) associated with few entities, those are editable for all currently active users (U1, U2). Assume that, we have 2 rules (R1, R2). Our requirement is no two users can edit, delete or modify a specific rule at same point of time.
Eg: If U1 update R1 then U2 has to wait till U1 release R1. If U1 update R2 then U2 have provision to update R1 since R1 is not locked by any user. I hope you are clear about the requirement.
Now, to ensure the above discussed functionality we implemented a method which uses Interlocked Class in threading namespace (VS.NET & C#). This approach in fact helps us while avoiding concurrent user access over a specific instance on a specific time using some flag value. But the problem is, it locks the entire rule collection (R1, R2) even thou there is no concurrent user. I presume, this is because of the way we model the class and is a collection (rule collection).
Eg: If I have N rules in rule collection, it doesn’t mean that I need to lock all N rule objects in the rule collection. But I only need to lock specific rule (subset of rule collection), those are currently used by some logged users. And ensure all other non affected rules are free from lock.
I did have a thought on the object level locking using .Net object locking mechanisms. But this is practically impossible to implement locking mechanism for each and every functionality.
FYI: It is small product which has 54 projects (30 services, test projects, script) in C#.NET. And the product has its 70% of functionalities in place. So a major rework in object level is not practical at this moment since it has to go through lot of review and regression process.
I hope you are clear with respect to the problem statement.
Can you explain me which method would be feasible in such scenario ?
How will i make sure only the object lock is available for the object which is currently i use and not other objects in the collection?
And how will I ensure object level isolation than locking an entire collection?
Do we have any proved patterns for this kind of problems?
Thanks in advance.
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.