473,569 Members | 2,834 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 RequirementColl ection. 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 requirementColl ection, 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


Jul 21 '05 #1
0 2115

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

Similar topics

18
9177
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 advice from the advanced/pro users... some advice that would help me to grow up! I know that many (if not all) the stuff that was a hassle in ASP 3...
16
2994
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 example dsParts.xsd and including that in the data tier. I then will create a class that looks like this Public Class CPart Inherits dsParts
11
9223
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 C++. I find my self sometimes, trying Object app = Object(); Object *app = Object(); Object app = new Object();
27
3456
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 seminal work or lackluster http://www.gotw.ca/resources/clcm.htm for info about ]
136
9250
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 code was littered with document.all and eval, for example, and I wanted to create a practical list of best practices that they could easily put to...
1
2271
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 Struction my solution in numerous projects ie 1. Webpage Files(ui) 2. Classes
0
1681
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 design of the database for a new project, but I am unsure as to the best practice when one wants to store data relating to combinations of...
14
2599
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 to use web services, but we have like hundreds of different methods you can call and what I wanted to do, is add a couple of generic webmethods...
6
2753
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 intensive, so would prefer to retrieve the info once at the beginning of the session, and have the data persist for the session 3) several forms in...
0
7605
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7665
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6277
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2105
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
933
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.