From: emitrax on
On 13 Apr, 23:55, "Thiago A." <thiago.ad...(a)gmail.com> wrote:
> > > I'm finding myself analyzing a fairly complex system log (library),
> > > where amazingly for me, many classes have lots, or even only, static
> > > methods! What strikes me the most, is that static methods are used
>
> Comparing static function X::F of X with non-member function F() I
> would choose static function in these situations:
>
> * X is a trait class; Group of functions used in templates
> * F is needs access to private or protected parts of X
>
> In other cases I would choose non-member function.
>

Well, the class that inherits has only static methods and
no private or protected parts. It only has a static private
object of the base class.

I'm starting to that Java theory is the _ONLY_ theory here.

S.


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: emitrax on
On 14 Apr, 09:50, Tony Delroy <tony_in_da...(a)yahoo.co.uk> wrote:
> On Apr 14, 6:55 am, emitrax <emit...(a)gmail.com> wrote:
>
>
> > STATICCLASSNAME::STATICMETHOD::Method(bla,bla,bla);
>
> Some people - like John Lakos, author of Large Scale C++ Design or
> whatever it's called - have written and used corporate coding
> standards that demand classes/structs be used in place of namespaces
> precisely because it forces the above usage (not sure if he still
> does). You could read that book if you're really keen, but off the
> top of my head, some of the kinds of justifications include:
>

I actually have that book. Didn't get to that point yet though.
I'll have a look thanks.

>
> * by being explicit, the code becomes less context-dependent and hence
> (supposedly) easier to debug/maintain
>
>
> * avoiding introduction of ambiguity should a name conflict arise in
> distinct namespaces "used" by the same code
>

To this point I must add that the public static object members have
been
named with all upper case letter, like ERR! This latest one in fact,
created
a conflict with another header that define'd an error code with that
name (ERR).

>
> * enforcing a reliable association of interface and "physical" files
> (as class content can't be declared in multiple files the way
> namespace content can).
>

Could be...

Thanks,
S.


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: Ulrich Eckhardt on
emitrax wrote:
> On 14 Apr, 02:43, Maciej Sobczak <see.my.homep...(a)gmail.com> wrote:
[ about classes with only static functions ]
>> Yes, that's strange. A "namespace extension", perhaps?
>>
>> Are there any objects created of these types?
>>
>
> No. Those classes are stated to be non-instantiable.

"stated" in documentation or in code? If the author doesn't even know how to
make a class non-instantiable, they probably didn't know too much about
C++, so you can rule out a proper design decision.

Uli

--
Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: emitrax on
On 14 Apr, 13:18, Maciej Sobczak <see.my.homep...(a)gmail.com> wrote:
> On 14 Kwi, 09:50, Tony Delroy <tony_in_da...(a)yahoo.co.uk> wrote:
>
> > > STATICCLASSNAME::STATICMETHOD::Method(bla,bla,bla);
>
> > Some people - like John Lakos, author of Large Scale C++ Design or
> > whatever it's called - have written and used corporate coding
> > standards that demand classes/structs be used in place of namespaces
> > precisely because it forces the above usage
>
> Note that you can also force the above usage by banning the "use
> namespace" construct.
>

I don't mean to go OT, but how do you achieve that?
You mean you can prevent the user from using "use namespace
mynamesapce"?

S.

--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: Daniel T. on
Tony Delroy <tony_in_da_uk(a)yahoo.co.uk> wrote:
> On Apr 14, 6:55 am, emitrax <emit...(a)gmail.com> wrote:
> > On 13 Apr, 11:59, Ulrich Eckhardt <eckha...(a)satorlaser.com> wrote:
> > > emitrax wrote:
> > >
> > > > I'm finding myself analyzing a fairly complex system log
> > > > (library), where amazingly for me, many classes have lots, or
> > > > even only, static methods!
> >
> > > Typical reason: Bad code quality. Some people seem to think "OOP
> > > is a must" so they put everything into a class, i.e. abuse classes
> > > as mere namespaces.
> >
> > Yes, that's what my colleague and I were wondering. Why not using
> > namespaces in the first place, if the library has to be used with
> > the following syntax
> >
> > STATICCLASSNAME::STATICMETHOD::Method(bla,bla,bla);
>
> Some people - like John Lakos, author of Large Scale C++ Design or
> whatever it's called - have written and used corporate coding
> standards that demand classes/structs be used in place of namespaces
> precisely because it forces the above usage (not sure if he still
> does).

Take note that Lakos' book was published in 1996, two years before the
standard was finalized. As I recall (and I might recall incorrectly,) at
that time, few C++ compilers handled namespaces and using classes as
namespaces was an OK idea. To the OP, how old is this library?

However, using all uppercase for class names has never been kosher in
C++, that came from Eiffel.

--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]