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

Class with all static members --> Is namespace() the right choice?

I just noticed the following class design in a module.
class testClass
{
public:
static long utilFunc1() ;
static long utilFunc2() ;
static long utilFunc3() ;
private:
testClass(){};
~testClass(){};

static someClass1* someObj1Ptr ;
static someClass2* someObj2Ptr ;
static someClass3* someObj3Ptr ;
};

The class design looks ugly for me. The implementation also gives the
feeling that, this class is just a placeholder for the utility
functions.
In that case, could I suggest to use namespace instead of a class?
The only reason why I hesitate to suggest that is, the class also
contains some
members. Can still the namespace be the correct choice here?

Kindly clarify!
Jul 22 '05 #1
2 1435
* qazmlp:
I just noticed the following class design in a module.
class testClass
{
public:
static long utilFunc1() ;
static long utilFunc2() ;
static long utilFunc3() ;
private:
testClass(){};
~testClass(){};

static someClass1* someObj1Ptr ;
static someClass2* someObj2Ptr ;
static someClass3* someObj3Ptr ;
};

The class design looks ugly for me. The implementation also gives the
feeling that, this class is just a placeholder for the utility
functions.
In that case, could I suggest to use namespace instead of a class?
The only reason why I hesitate to suggest that is, the class also
contains some
members. Can still the namespace be the correct choice here?

Kindly clarify!


It seems the class could reasonably be split into two classes, one
with the non-static members and one with the static utility functions.

A class with only static members _can_ be useful e.g. as a template
argument.

But from what you write that seems unlikely.

The alternatives are (1) placing those functions at namespace
scope, or (2) using a singleton, or (3) re-design, who knows
what might pop out?

There is not enough information to recommend any specific design.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #2
qazmlp wrote:
I just noticed the following class design in a module.
class testClass
{
public:
static long utilFunc1() ;
static long utilFunc2() ;
static long utilFunc3() ;
private:
testClass(){};
~testClass(){};

static someClass1* someObj1Ptr ;
static someClass2* someObj2Ptr ;
static someClass3* someObj3Ptr ;
};

The class design looks ugly for me. The implementation also gives the
feeling that, this class is just a placeholder for the utility
functions.
In that case, could I suggest to use namespace instead of a class?
The only reason why I hesitate to suggest that is, the class also
contains some
members. Can still the namespace be the correct choice here?
...


A major reason to use class instead of namespace in this case is that
class can be used as template argument (namespace cannot).

--
Best regards,
Andrey Tarasevich

Jul 22 '05 #3

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

Similar topics

5
by: BigMan | last post by:
Does the standard define the order in which static members of a class are created and initialized?
3
by: Ryan Steckler | last post by:
I found this behavior while trying to implement a singleton class. Below is a somewhat more straight forward example, though admittedly less useful in real life. The basic problem is that when a...
6
by: mflanagan | last post by:
I have unmanaged C++ program that will load a managed C++ dll and then call a function in that dll. The managed C++ routine will call some C# routines. The unmanaged C++ main program will make...
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...
11
by: Henryk | last post by:
I have something like class Params { public: const static char nOne = 1; const static int nTwo = 2; const static char nThree = 3; }; This is just a wrapper for globally used parameters in...
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() { //...
2
by: Tim Van Wassenhove | last post by:
Hello, When i read the CLI spec, 8.10.2 Method inheritance i read the following: "A derived object type inherits all of the instance and virtual methods of its base object type. It does not...
5
by: Andy B | last post by:
I have a class that I want to make static but it uses some objects that are instance objects. I keep getting a compiler error saying something about using instance objects in a static class or...
5
by: Timothy Madden | last post by:
Hy static members of non-integral type need to be declared in the class, but defined (and constructed or initialized) outside the class. Like this class SystemName { public:
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
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
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,...
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...
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...

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.