Re: Forcing sub-classes to implement Constructor
Rich Dougherty <[email protected]>
| Newsgroups | gmane.comp.windows.devel.java.advanced |
|---|---|
| Message-ID | <[email protected]> |
On 8/10/07, Attila Szegedi <[email protected]> wrote: > 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 :-) I think the only time you'd need to worry about no-arg constructors is if you extend a class that's not Serializable. http://java.sun.com/javase/6/docs/api/java/io/Serializable.html > 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 can probably spot a few of things at compile time with something like FindBugs. eg. http://findbugs.sourceforge.net/bugDescriptions.html#SE_NO_SUITABLE_CONSTRUCTOR But I agree that functional tests are probably the best idea. FindBugs wouldn't be able to tell, for example, whether the entire object graph that you want to send is actually serializable. The best thing for that would be a test. Rich -- Rich Dougherty http://www.rd.gen.nz/ =================================== This list is hosted by DevelopMentor® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com