Which is why the use of an interface instead of a class makes no sense. It merely makes bad coding possible and does nothing else for you.

Jack, your not saying using an interface in general is bad I hope?!? :)

This is an interesting discussion, but obviously off topic, so I've marked my response as such. Hopefully everyone else follows suit.

I think I agree with the idea of not putting constants in interfaces as well. The idea of an interface is to describe a contract between an object and clients of that object. It doesn't seem to me that an interface then should contain any details that pertain to how it's constituent functions perform their actions, or how any client will actually make use of an object implementing that interface.

On the other hand...

If I have a constant pool in a class, i have to protect it from
instantiation (giving it private constructor) and give it a special name, so
it's clear for my co-developers, which both means more work to me. An
interface is uninstantiable by definition (since there are no classes which
implement a constant interface).

...this is a reasonable point! The only thing I would say Leon is that yes, I would think a decent name for a "constants class" would be a good idea (but that's *always* true of naming classes), but as far as protecting it from instantiation goes, I would say: why worry about it? It seems clear that such a class shouldn't be instantiated, but there's no harm if it is, right? I suppose you could point out memory usage and performance implications of an object creation that wasn't necessary, but I don't think those are major concerns. I'd agree it would be a bit of a code smell though, not something I'd want my team members doing.


I do think you make a reasonable argument though, that's the bottom line. Interesting debate for sure both ways!

--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to