473,394 Members | 1,481 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Best practices question - Data Structure design.

Hi everybody,

I would like to hear your thoughts on the following problem.

We have the following classes.

Class Exam
int ID*
int Version*
string Name

Class Requirement
Int version*
String name
Int modelnumber*
In every class the fields marked with a star define class' uniqueness.
There are also collections that contain these classes, and they are strongly
typed. ExamCollection and RequirementCollection. The collections check the
items for uniqueness and validity before they add them.
Now, when user asks us for an item from the collection, we cannot really
give him the internal class, because, the user can change the item in a way,
that will cause duplicates in the collection or render the item invalid.
Thus, we have to clone the item, and return the clone. After the changes to
the cloned item were made, we have to try to add it to the collection. If
the item with the composite key already exists, we need to update it. If it
doesn't we need to add it to the collection. And by the way, we also have to
make sure that the item we are about to add is valid; that is why Exam and
Requirement have function Valid() which returns a state of validness of the
item.

Every exam can be linked to multiple requirements, and one requirement can
have multiple exams. The best way to maintain the links is to create a
LinkManager class which will take care of the problem. But, since real
addresses of the objects are not available, we need to store the keys of the
related objects. So, every time I want to know which requirements reference
a specific exam, I need to get exam's key, ask LinkManager to find all the
requirements' keys that are related to the exam's key. Then ask the
requirement collection to return clones of all the requirements with the
following keys.
I could have used a Singleton that will maintain all the relations, but then
I will allow cloned items, that do not belong to the collections create
links, which is a logical error. (All collections contain valid and unique
items. Everything was checked during adding.). Exams might reference
requirements that are outside of requirementCollection, and that is not
acceptable.

I described my solution to the problem. My concern is the penalty for
cloning items and also all the iteration times (every time we iterate
through the collection, we need to clone items that are being enumerated.
Otherwise, foreach loop will be able to change it.)

I would love to hear some ideas of yours on this design issue. Any
suggestions or critique is welcome. Or links, or sources.... Anything that
is somewhat related to the issue.

Take care,
Sasha


Nov 20 '05 #1
0 887

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Lorenzo Bolognini | last post by:
Hi all, i am an ASP developer with 1,5+ years experience. After sneaking around the ASP Classic world for a bit i became a bit dissatisfied of my ASP code practices so i'd like to have some...
0
by: Sasha | last post by:
Hi everybody, I would like to hear your thoughts on the following problem. We have the following classes. Class Exam int ID* int Version* string Name
16
by: D Witherspoon | last post by:
I am developing a Windows Forms application in VB.NET that will use .NET remoting to access the data tier classes. A very simple way I have come up with is by creating typed (.xsd) datasets. For...
11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
27
by: Stuart Gerchick | last post by:
C++ Coding Standards : 101 Rules, Guidelines, and Best Practices by Herb Sutter, Andrei Alexandrescu is now a month or so away from release. What is people's opinion on this...is it going to be a...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
1
by: Vincent V | last post by:
Hey i am just starting a new project and from the start i want to make sure my app is as Object Orientated as possible I have a couple of questions in relation to this Question 1: Should i...
0
by: Louis Aslett | last post by:
I hope this is the correct newsgroup for this query (if not please give me a pointer to where is best): I understand the theory of normalisation etc and am trying to follow best practices in the...
14
by: Bert Vandenberghe | last post by:
Hi, I was wondering if there are any best practices on the creation of webmethods? I'll try to explain this a little more: My problem is that we are changing an existing (large) DCOM application...
6
by: mirandacascade | last post by:
Assume the following: 1) multi-user environment 2) when user opens app, want to run some code that retrieves some information specific to the user...retrieving this information is somewhat i/o...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
0
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...

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.