Re: Forcing sub-classes to implement Constructor
Attila Szegedi <[email protected]>
| Newsgroups | gmane.comp.windows.devel.java.advanced |
|---|---|
| Message-ID | <[email protected]> |
Doesn't this JMS implementation use Java object serialization? If so, you don't need constructors -- serialization is able to instantiate objects without going through constructors :-) (reasoning being, they aren't constructed, but deserialized; they were constructed already in the sending JVM before they were serialized). Other than that, a good functional test suite will sort of "force" this. Since you can't really force it at compile time (except Brian's annotation idea, but then what happens if you forget to add the annotation, right?), you should therefore force it by suitable tests that you add to your build system. You'll do that anyway, except if it isn't in your build system then you'll rely on the test system that exists implicitly in every project, the one named "ship to customer and wait" :-) (aww, now I sound as if I were a TDD advocate) Attila. On Fri, 10 Aug 2007 09:38:26 +0200, Roger Jakobsen <[email protected]> wrote: >> > We have this JMS implementation. The messages are classes that inherit > from > the NetMessage class. The NetMessage class defines multiple abstract > methods > like readFromStream(...) and writeToStream(...), etc. Now, if someone > issues > a NetMessage without an empty constructor the JMS implementation will be > unable to re-create, or instantiate, it on the receiving side. It would > be > nice to force subclasses to implement an empty constructor. > > Roger > =================================== This list is hosted by DevelopMentor® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com