Connecting Tech Pros Worldwide Forums | Help | Site Map

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

qazmlp
Guest
 
Posts: n/a
#1: Jul 22 '05
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!

Alf P. Steinbach
Guest
 
Posts: n/a
#2: Jul 22 '05

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


* qazmlp:[color=blue]
> 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![/color]

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?
Andrey Tarasevich
Guest
 
Posts: n/a
#3: Jul 22 '05

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


qazmlp wrote:[color=blue]
> 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?
> ...[/color]

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

Closed Thread