[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.8

Globally sharing instances of objects

Asked by Labelsoft in Software/Systems Design, Design & Methodology, .NET

Tags: OO, OOP, instance, instances, global, globally, object, objects, vb, c#, .net, design pattern, architecture, share, sharing, best practise

Dear experts,

I am developing a 3 tier application (in VB.NET 9 with framework 3.5 but this doesn't matter much) which uses a given XML file as DB. Because of this XML file I want to create an application which retrieves all the data at start up and creates + populates all objects accordingly. My philosophy for this app is to retrieve every instance of an object once. And this credo is actually what gave me problems to solve this the cleanest way possible (which I always strive for).

For this to work let's say I made a module named "MainModule" with a public property named "Categories" typed as "CategoryCollection". CategoryCollection is a class which inherits from BindingList(Of Category). Category is eventually the class with the data of a category. Simple so far right?
The same module also has a property named Stores which is typed as "StoreCollection". StoreCollection also inherits from BindingList(Of Store). Store is the class with the data from one store obviously. But the Store class has a property named "MyCategory" which is typed as Category.
To make sure I don't need to retrieve the category again from the XML file for this store and create another instance for the same category (remember the holy credo I set for myself), I simply find the correct category in the "Categories" property in "MainModule" (this looks like something like store.MyCategory = MainModule.Categories(0)). --> Let's pretend I found out the correct category is category where index = 0.

This is a very simple example obviously. In my application a category instance can be needed by 3 different other classes or something. Plus the fact that I sometimes need it down the line of 4 objects (or more!). That is why I don't want to pass the category collection along through constructors. It will pass 3 objects who don't need it first so I can facilitate the 4th. That can't be the best practise we can come up with right? This is why I used a module. But I don't like this solution. It's a bit ugly in my opinion. I don't want to approach a module from within a class. I also don't want to make a class with shared properties, because that sounds like the same thing as a module to me (in practise ofcourse). The singleton pattern won't work I think, because i'll have to hold that one single instance in... a what? A module? Same problem...

So you guys see my problem right? I just want to hear what you guys think? What do you guys consider the cleanest way of getting this show on the road?
[+][-]11/04/09 03:32 AM, ID: 25738257Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/04/09 03:35 AM, ID: 25738268Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/04/09 03:36 AM, ID: 25738278Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/04/09 03:37 AM, ID: 25738284Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/04/09 03:42 AM, ID: 25738308Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/04/09 04:08 AM, ID: 25738485Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/04/09 04:32 AM, ID: 25738633Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/04/09 04:40 AM, ID: 25738677Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/04/09 05:07 AM, ID: 25738869Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/04/09 05:13 AM, ID: 25738927Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/04/09 05:55 AM, ID: 25739288Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/05/09 12:19 AM, ID: 25747553Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/05/09 12:21 AM, ID: 25747558Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/05/09 07:33 PM, ID: 25756408Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/05/09 11:57 PM, ID: 25757398Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/06/09 02:31 PM, ID: 25763659Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Software/Systems Design, Design & Methodology, .NET
Tags: OO, OOP, instance, instances, global, globally, object, objects, vb, c#, .net, design pattern, architecture, share, sharing, best practise
Sign Up Now!
Solution Provided By: Volox
Participating Experts: 2
Solution Grade: A
 
 
Loading Advertisement...
20091111-EE-VQP-89 - Hierarchy / EE_QW_3_20080625