473,396 Members | 2,013 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,396 software developers and data experts.

C# Design Help

Hi everyone, I have a general class design question. I come from a
VB5-6 background where I made applications that used an active x dll
to access the database. In the VB world each class was in a seperate
file and I was able to have a module that they all shared that had
global variables, like my ado connection object. In C sharp it looks
like all my class can be contained into one .cs file, so my question
is where would I put any variables that I want all my classes to have
access to. I have been experimenting a little and I looks like I
could have one top level class and then put all my sub classes inside
that class but is this the right way to design it?
Nov 15 '05 #1
2 1183
For shared variables, there are a couple of methods to possibly use:

1. Use static variables and properties, which retain their values.
2. Create a singleton. This ensures that there is one instance alive that
can be shared.

Both are better than embedding classes to facilitate "global" vars.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************** ********************
Think Outside the Box!
************************************************** ********************
"Frank" <fp***@hotmail.com> wrote in message
news:bd**************************@posting.google.c om...
Hi everyone, I have a general class design question. I come from a
VB5-6 background where I made applications that used an active x dll
to access the database. In the VB world each class was in a seperate
file and I was able to have a module that they all shared that had
global variables, like my ado connection object. In C sharp it looks
like all my class can be contained into one .cs file, so my question
is where would I put any variables that I want all my classes to have
access to. I have been experimenting a little and I looks like I
could have one top level class and then put all my sub classes inside
that class but is this the right way to design it?

Nov 15 '05 #2
Hi Frank,

You can decide if you want all the classes in the same file or in different
files, it's up to you to decide.

You are right regarding that all the variables must be inside a class, you
can declare a class with only static members representing your global
variables, so they are accesible from anywhere by using:
ClassName.VariableName

I suggest you that instead of using public variables you keep them private
and use properties instead.
hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Frank" <fp***@hotmail.com> wrote in message
news:bd**************************@posting.google.c om...
Hi everyone, I have a general class design question. I come from a
VB5-6 background where I made applications that used an active x dll
to access the database. In the VB world each class was in a seperate
file and I was able to have a module that they all shared that had
global variables, like my ado connection object. In C sharp it looks
like all my class can be contained into one .cs file, so my question
is where would I put any variables that I want all my classes to have
access to. I have been experimenting a little and I looks like I
could have one top level class and then put all my sub classes inside
that class but is this the right way to design it?

Nov 15 '05 #3

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

Similar topics

36
by: Andrea Griffini | last post by:
I did it. I proposed python as the main language for our next CAD/CAM software because I think that it has all the potential needed for it. I'm not sure yet if the decision will get through, but...
3
by: Rushikesh | last post by:
I am designing a WEB BASED Accounting Software with ASP and SQL Server. For this I need some help for the Database design. My design is as follows. I)User table: User_id, UserName..... Users...
7
by: Bora Eryilmaz | last post by:
I am working on designing a set of abstract classes that would be subclassed by the users and they have to implement the abtract (virtual) methods. Does anybody know of a good reference on...
9
by: sk | last post by:
I have an applicaton in which I collect data for different parameters for a set of devices. The data are entered into a single table, each set of name, value pairs time-stamped and associated with...
7
by: Shimon Sim | last post by:
I have a custom composite control I have following property
20
by: Brad Pears | last post by:
I am completely new to vb .net. I am using visual Studio 2005 to redo an Access 2000 application into a .net OO application using SQL Server 2000 - so a complete rewrite and re-thinking of how...
0
by: YellowFin Announcements | last post by:
Introduction Usability and relevance have been identified as the major factors preventing mass adoption of Business Intelligence applications. What we have today are traditional BI tools that...
9
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...
9
by: AceKnocks | last post by:
I am working on a framework design problem in which I have to design a C++ based framework capable of solving three puzzles for now but actually it should work with a general puzzle of any kind and I...
4
by: Ken Fine | last post by:
I've been living with a frustrating issue with VS.NET for some months now and I need to figure out what the problem is. Hopefully someone has run into the same issue and can suggest a fix. I...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.