Namespace vs Class

Problems compiling? Don't understand the source code? Don't know how to code your feature? Post here.

Moderator: Moderators

Locked
Pothead
Posts: 223
Joined: 2005-01-15 06:55

Namespace vs Class

Post by Pothead » 2005-12-11 08:07

Namespace vs Class
For example, since Util and Text are collections of functions, and not collections of objects, shouldn't the be defined as a namespace, instead of a class. ?

GargoyleMT
DC++ Contributor
Posts: 3212
Joined: 2003-01-07 21:46
Location: .pa.us

Post by GargoyleMT » 2005-12-11 09:07

We have had a discussion about this in the past, but my log greppage isn't helping turn up the conversation. :)

FarCry
Programmer
Posts: 34
Joined: 2003-05-01 10:49

Re: Namespace vs Class

Post by FarCry » 2005-12-14 00:01

Pothead wrote:Namespace vs Class
For example, since Util and Text are collections of functions, and not collections of objects, shouldn't the be defined as a namespace, instead of a class. ?
They should indeed. Besides the fact that neither Util nor Text describe a single concept or even something you might want to create an object of, a namespace has also several advantages above a class (can be re-opened, is more convenient to use with "using" declarations, functions are "static" by default).

Pothead
Posts: 223
Joined: 2005-01-15 06:55

Re: Namespace vs Class

Post by Pothead » 2005-12-14 06:30

Pothead wrote:are collections of functions, and not collections of objects
That's a bad example, reading a bit more . . . . even classes of objects and templates should be in namespaces. A namespace is used to group a bunch of code which is "logically related".
:shock:
GargoyleMT wrote:We have had a discussion about this in the past, but my log greppage isn't helping turn up the conversation. :)
And ideas about the results of this discussion ?
FarCry wrote:They should indeed. Besides the fact that neither Util nor Text describe a single concept or even something you might want to create an object of, a namespace has also several advantages above a class (can be re-opened, is more convenient to use with "using" declarations, functions are "static" by default).
Thanks for the clear response. hehe, and telling me new stuff (about being static by default) :)

GargoyleMT
DC++ Contributor
Posts: 3212
Joined: 2003-01-07 21:46
Location: .pa.us

Re: Namespace vs Class

Post by GargoyleMT » 2005-12-14 17:33

Pothead wrote:And ideas about the results of this discussion ?
What FarCry said. cologic probably had something to say, maybe Trem or arne too. But that was the gist of it.

Locked