473,705 Members | 3,166 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Design question - static list in class

Hi all

I have a design which models a telephone system. Roughly the design has
these two items:

device class which models an extension on the telephone system. The device
constructor takes a extension number. So program starts by creating a
device object for each extension on the telephone system.

Each device object contains a static list of calls. Calls are modelled by a
class object. The class object takes an extension number in its destructor.

There are various find functions to find a call on a device. Usually on a
device there will be 0, 1 or 2 calls.

The list of calls in the device object is static because sometimes a device
object is created on the stack simply to find a call on the device and maybe
report on its status. If the call list were NOT static then I would get a
zero size call list each time I created the device object on the stack. Not
what I want.

I also have a device list - there is only ever one instance of the class
which accesses the device list. So the number of items in the device list
(a std::list) is set after the program starts.

Eg I get hold of the correct device object like this (device is the
extension object);

device* pDev=FindDevice ByDN(dn);

FindDeviceByDN retrieves a copy of the relevant device object in the device
list.

Then I might do something like this:
call* pCall=pDev->GetCallbyCallI D(callid);
I am concerned that the static call list might be bad design. But not sure?
What do people think? Does this design seem ok? Anyone see a better
design?

Angus

Oct 11 '08 #1
1 2257
"Angus" <no****@gmail.c omkirjutas:
I have a design which models a telephone system. Roughly the design
has these two items:

device class which models an extension on the telephone system. The
device constructor takes a extension number. So program starts by
creating a device object for each extension on the telephone system.

Each device object contains a static list of calls.
If the "static list" means static data in the C++ sense, then no, each
device object does not contain a list of calls; all device objects are
rather sharing a single list.

Calls are
modelled by a class object.
Sorry, cannot grok this...
The class object takes an extension
number in its destructor.
neither this...

I believe you should better post some sketch in C++ to get some useful
answers.

In general, static data is bad for reentrant code and for multithreading.
It should be used only if all running threads must see and/or alter the
same data state (with proper synchronization , of course). And if your
software is not using multithreading yet, the chances are good IMO that
it might to start to do that in a couple of years, just to make some use
of the multitude of cpu cores the new processors are sporting.

All the best
Paavo
Oct 14 '08 #2

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

Similar topics

3
3144
by: Omer van Kloeten | last post by:
The Top Level Design: The class Base is a factory class with a twist. It uses the Assembly/Type classes to extract all types that inherit from it and add them to the list of types that inherit from it. During run time, using a static method, the class creates an instance of the derived class using the Activator class and returns it. This design pattern is very similar to the design pattern applied by the Assembly class. The twist is...
29
3569
by: MP | last post by:
Greets, context: vb6/ado/.mdb/jet 4.0 (no access)/sql beginning learner, first database, planning stages (I think the underlying question here is whether to normalize or not to normalize this one data field - but i'm not sure) :-) Background info:
2
2398
by: desigan | last post by:
Hi All, I am new to C# and I am facing a problem with respect to design and deployment of C# program. My application needs the following: a) A console program will do some data processing and will store the results in a static variable in Singleton class. b) A GUI program will have one button and on clicking the button, it will access the same static variable in Singleton class.
8
1699
by: | last post by:
I'm looking for some design guidance on a collection of projects I'm working on. The project involves a bunch of websites constructed out of a collection of user controls. Different user populations with different access rights and "roles" will be visiting the site. I will be using ASP.NET 2.0's membership, roles, and profiles stuff to manage access. User controls need to be visible or not visible depending on user role. In some...
9
2822
by: Grizlyk | last post by:
Somebody have offered std colors to C++ in the msg here: http://groups.google.com/group/comp.lang.c++/browse_frm/thread/2e5bb3d36ece543b/1acf6cd7e3ebdbcd#1acf6cd7e3ebdbcd The main objection to the including "colors markup" is useless of the marks, the marks is unneccessary extra information. The most used way to make colored view of C++ programs is usage of classes of C++ language words (already included in C++): reserved words, user...
0
3690
by: Paul Hadfield | last post by:
I'm looking for thoughts on the "correct" design for this problem (DotNet 2.0 - in winforms, but that's not so important). I've got two combo boxes (combo1 and combo2), both are populating via database calls (using a separate DB handler class). "combo1" contains a list of countries and is fairly static, it can be added to but no other external events cause a change in its population. "combo2" however is populated with a list of options...
13
2706
by: John Kraft | last post by:
Friends, I'm working on some crud stuff, and I was looking for opinions on the subject. Below, I have pasted some VERY simple sample code. Class2 is a "traditional" crud type object. In a real example, these objects would probably implement some kind of ICrud interface with the common methods. I'm finding that many times, though, I want to use these objects as simple data objects, and I don't need all the database functionallity.
1
1609
by: mattmao | last post by:
I am brand new to C#.NET so here is my trial on this lab exercise: using System; using System.Collections.Generic; using System.Text; using System.Collections; namespace lab02exec { public class Program
5
1734
by: pgrazaitis | last post by:
I cant seem to get my head wrapped around this issue, I have myself so twisted now there maybe no issue! Ok so I designed a class X that has a few members, and for arguments sake one of the members Y is the location of a file to be read. The original design assumes that this class will be instantiated and each instance will happily mange its own members. (ie One file location per instance...no thread-safety). Now another class A...
0
8768
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8690
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9274
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9139
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8979
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7895
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4704
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3138
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
2
2491
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.