Wednesday, November 6, 2013

Checkstyle idea - require toString() method for Classes

toString() is required for classes that do logging as error to print context of them-self and around.

it might be reasonable to put in toString() only simple types fields that are provided by setXXXXX().

Johua Bloh idea about toString() for classes - Effective Java 2 book - "Item 10: Always override toString" - http://jtechies.blogspot.com/2012/07/item-10-always-override-tostring.html.

Having useful toString() make logging of context during error a simple and pleasant task.

Questions: What criteria we could follow to make a Check that will not force all Classes to have toString() on domains and critical for logging?

Override toString() everywhere is not practical, so we need figure out distinctive characteristics of Classes that have to do it.
- Class that is POJO
- ....

if somebody have ideas please share them on https://groups.google.com/forum/?hl=en#!forum/sevntu-checkstyle or https://groups.google.com/forum/?hl=en#!forum/checkstyle-devel

No comments:

Post a Comment