What comments do you put on an unimplemented method?
By mr_mlk
@mr_mlk (364)
August 11, 2008 12:56pm CST
Every now and again I end up implementing an interface and the interface having one or two methods that does not make sense for the class to implement (such as a read-only list or a custom read-only Data Source). Natrually I have it throw a NotImplemenetedException so if it is called any problems are caught early. But the question of what comments do I write shows up. I could just do:
/** Unimplemented. Always throws NotImplementedException.
* {@inheritDoc}
*/
So I don't have to fill in any @param tags and/or the @return tag. But it does not clearly state that the params are ignored and it will never return normally. But the alternative:
/** Unimplemented. Always throws NotImplementedException.
* @param param1 Ignored
* @return Never returns normally.
*/
can be quite long winded. Esp. for what is just a NO-OP.
So which do/would you use and why?
2 responses
@spalladino (17891)
• United States
11 Aug 08
I would use the first one because
"Always throws NotImplementedException"
says it all. As I see it, you really don't need to get into specifics.