473,378 Members | 1,312 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,378 software developers and data experts.

Static classes: to use or not to use?

I know it's a stupid question but...
I want to use a class that represents the current user of my application,
another one that reads position from a GPS receiver and another one that
reads RFID tags from a reader.
I don't want to create a new user each time a log in appens (only one login
at a time: mobile device) and I do not want to create a new object each time
I read position or a tag, so it's right to use static classes and to update
static fields (e.g. GPS.position or Tag.Id) every time a read happens?

Thank you.
Bye,
Luigi.
Apr 18 '07 #1
1 1376

Hi,

"BLUE" <bluewrote in message
news:46***********************@reader2.news.tin.it ...
>I know it's a stupid question but...
I want to use a class that represents the current user of my application,
another one that reads position from a GPS receiver and another one that
reads RFID tags from a reader.
I don't want to create a new user each time a log in appens (only one
login at a time: mobile device) and I do not want to create a new object
each time I read position or a tag, so it's right to use static classes
and to update static fields (e.g. GPS.position or Tag.Id) every time a
read happens?

Yes, it's ok.

Personally I would make the user a Singleton class. You will create an
instnce (and only one) at any moment.

The GPS & RFID classes should be static.
One thing you should pay especial attention is the events of these classes.
You may have more than one form that receive events from these classes. if
this is the case you will need to hook/unhook the handlers as you show/ihde
the forms.
Apr 18 '07 #2

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

Similar topics

5
by: Thomas Matthews | last post by:
Hi, I have three classes: Category Author Publisher Each of these classes stores its information into a database table of <ID, text>. (They are fields that have a foreign key.) There is...
9
by: Laban | last post by:
Hi, I find myself using static methods more than I probably should, so I am looking for some advice on a better approach. For example, I am writing an app that involves quite a bit of database...
4
by: Bryan Green | last post by:
So I'm working on a project for a C# class I'm taking, where I need to keep some running totals via static variables. I need three classes for three different types of objects. The base class and...
11
by: Kevin Prichard | last post by:
Hi all, I've recently been following the object-oriented techiques discussed here and have been testing them for use in a web application. There is problem that I'd like to discuss with you...
6
by: MSDNAndi | last post by:
Hi, I have a baseclass (non-static) with some static and some non-static methods/fields/properties. In the baseclass in one of the static methods I need to do something like " somelogic...
4
by: DBC User | last post by:
I have a class with bunch of static methods. I could regourp all the static methods into seperate 3 or 4 classes. I was thinking about using Singlton pattern for all these 4 classes so that it...
6
by: GroupReader | last post by:
In my app, I have two very similar static classes. After long thought, I've decided *yes - keep them static*. - Sometimes I will want to use Static Class A, and somtimes I will want to use...
2
by: mark4asp | last post by:
Q: Initialising and updating a class with only static members & database dependency I have a class with the following members: public static List<ACISACIS_List; static AssetClass() { //...
17
by: Juha Nieminen | last post by:
As we know, the keyword "inline" is a bit misleading because its meaning has changed in practice. In most modern compilers it has completely lost its meaning of "a hint for the compiler to inline...
9
by: puzzlecracker | last post by:
It looks like static classes can have non-static member classes -- does it make sense what I just wrote? If not, let me illustrate it: public static class Foo{ private struct Bar{ } }
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...

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.