[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!

8.7

OOP: Data Objects Design Pattern For Cascading

Asked by CyrexCore2k in C# Programming Language, Algorithms, SQL Query Syntax

Tags: OOP, Data Object, Business Object, Database, Table, Binding

I was curious if anyone had suggestions for the following problem I've been having.

Say I have the following tables in a database:

TABLE Images
{
    imageid int,
    location varchar(50)
}
TABLE Users
{
   userid int,
   imageid int
}
TABLE Games
{
   gameid int,
   userid int,
   imageid int
}

My question is, what would be a good design for gathering the information for a game, the image associated with that game, the user who created the game and the image associated with that user?

Lately my designs have design patterns similar to those below. However, since the Game object's image and the User object's image are going to be different I can't think of a scalable why to create all four objects (User, Game and two Image objects) using the results from a single query since the naming conventions will inevitably collide. Consider the case:

SELECT g.*, u.*, gi.*, ui.*
FROM Games g
   INNER JOIN Users u ON g.userid = u.userid
   INNER JOIN Images gi ON g.imageid = gi.imageid
   INNER JOIN Images ui ON u.imageid = ui.imageid
WHERE g.gameid = 1

Has anyone figured out a clever way to handle this kind of thing? I'd really like a scalable way to cascade object generation from a single query even in the event that multiple objects are gathering data from the same table.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
//In Image class:
Image CreateFromReader(SqlDataReader dr)
{
   Image ret = new Image();
   ret.imageid = int.Parse(dr["imageid"].ToString());
   ret.location = dr["location"].ToString();
   return ret;
}
 
// In User class:
User CreateFromReader(SqlDataReader dr)
{
   User ret = new User()
   ret.userid = int.Parse(dr["userid"].ToString());
   ret.image = Image.CreateFromReader(dr);
   return ret;
}
 
// In Game class:
Game CreateFromReader(SqlDataReader dr)
{
   Game ret = new Game();
   ret.gameid = int.Parse(dr["gameid"].ToString());
   ret.image = Image.CreateFromReader(dr);
   ret.user = User.CreateFromReader(dr);
   return ret;
}
[+][-]12/17/08 04:04 PM, ID: 23199596Accepted 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: C# Programming Language, Algorithms, SQL Query Syntax
Tags: OOP, Data Object, Business Object, Database, Table, Binding
Sign Up Now!
Solution Provided By: MikeDotNet555
Participating Experts: 3
Solution Grade: A
 
[+][-]12/17/08 02:33 AM, ID: 23191996Expert 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.

 
[+][-]12/17/08 10:09 AM, ID: 23196170Expert 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.

 
[+][-]12/17/08 10:34 AM, ID: 23196459Expert 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.

 
[+][-]12/17/08 12:54 PM, ID: 23198054Author 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.

 
[+][-]12/17/08 12:59 PM, ID: 23198121Author 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.

 
[+][-]12/17/08 02:11 PM, ID: 23198800Expert 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.

 
[+][-]12/17/08 02:32 PM, ID: 23198976Expert 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.

 
[+][-]12/17/08 02:49 PM, ID: 23199086Author 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.

 
[+][-]12/17/08 10:39 PM, ID: 23201102Author 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.

 
 
Loading Advertisement...
20091111-EE-VQP-92 - Hierarchy / EE_QW_EXPERT_20070906