<snip type="excerpt"> The only semantics that are associated with an interface are the ones that you enforce. A class can be an implementation of a particular interface, and that class has its own semantics. You may require that all classes that implement an interface follow a certain set of rules, but you can only enforce those rules using tests that you apply outside of the compiling environment. Your tests may be code walkthroughs or a conformance test framework, but even if you feel strongly that your interface implies a semantic contract, the only contract that is enforced by the language is that any class that implements the interface will include the signatures in that interface. </snip>
I agree, but I also think that there are definite advantages to attaching rules to an interface. See the java collections framework as an example. Certainly, you could implement a remove method that actually adds, but that would be stupid. This is why interfaces with attached semantics should come with conformance test suites. I think that the whole point is that there is no way to 100% safeguard against misuse when using an interface (or even any non-final class). ----- Original Message ----- From: "Berin Loritsch" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, March 18, 2004 7:55 AM Subject: [RRT] An interface is all you need > You know, that article that Bruce Eckel produced > (http://mindview.net/WebLog/log-0051) was thought provoking. Should > there be additional semantic meaning to an interface? I used to think > so, but now I don't. > > An interface is all you can enforce in code, and all you should expect > the user to respect. But that's just me. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
