Re: Do you currently use namespaces?

new topic     » goto parent     » topic index » view thread      » older message » newer message

ken mortenson wrote:
> 
> Matt Lewis wrote:
> 
> > Classes only resolve the issue until you have multiple classes with the
> > same name.
> 
> Perhaps in theory, but I've never actually seen a real world example (not
> that it couldn't happen.)  Any class would normally have many properties 
> and methods which would have no collision issues.

I see them all the time in, for instance, Java.  Different libraries often
have similar class names.  One common one that comes to mind is 'Query.'

> For the class name
> itself, most classes are those the programmer defines so those aren't a
> problem.

Only if you always roll your own.  I think most people use at least some
third party code, even if it's only from the standard library.  You have
no control over how those things are named.

> So 3rd party libraries are the only issue.  What about them?
> If in the form of two DLL's with the same name, you just put them into
> two different folders.  So that leaves a third party source library.  Again,
> you could simply have the library in a separate folder.

This is one way to disambiguate.  I assume you're thinking of something like
Java or perl, where file structure has meaning within the code.

> So I just don't see any possible problem with class name collisions. 
> Devil's advocate, how could I intentionally create a class name conflict?
> Of course, in VB, class names and file names are the same and there is one
> class per file.  That may not be the case if the classes are implemented
> in some different way.

It could still be a problem.  What if you're using two different libraries,
each of which define a class with the same name?  For example, what if you
have one library for using a database, and another for doing xslt stuff.
It's pretty easy to imagine that both might have a Query class, for instance.

The bottom line is that you need some sort of container which is in the 
control of the end user (at least, if you want *any* combination of 3rd
party code to be usable together).  You can use file structure.  Euphoria
doesn't use this.  It uses namespaces.

> > The information hiding is actually not *required* for this, though it could
> > make the job easier by reducing the amount of symbols available to any
> > particular scope.
> 
> Just as a principle, all symbols should have scope as limited as possible.

Yes, I think we all agree on this.

Matt

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu