Building a generic toString() method

Zarar Siddiqi’s blog post on talks about building a generic toString() method to dump out the contents of all the attributes of an instance, which of course is invaluable for debugging.

The thing is, one of the number one rules of architecture is to appreciate and understand what is already out there, what has been done before, and what you can reuse.

The Commons Lang library of useful code includes a ReflectionToStringBuilder class which does exactly the same thing.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.