Christian, I do something similar in my current toString() implementations, but without the class information right now. I generally try to come up with something brief, human readable and can be used as a reasonable default if someone were to just use it to build a prototype UI for an application. In that regard, YAML may not be a good choice, especially considering it's a multi-line format.
Yet I can see scenarios where YAML would be a good format. I'll have to think about this a little bit more. There are some YAML examples here http://www.yaml.org/start.html. Here's a quick example, let's say you have the following classes: class Car { String make; String model; Engine engine; /* Getters/setters omitted */ } class Engine { String code; float displacementInCC; } The Honda S2000 instance would be represented as YAML as follows: --- !arbitrary type descriptor, e.g., com.foo.Car make : Honda model : S2000 engine: code :f20c displacementInCC: 1997 On Sep 21, 2:25 am, Christian Catchpole <[EMAIL PROTECTED]> wrote: > I don't know nothing about YAML but my default toString goes a little > something like this.. > > return this.getClass().getSimpleName() + ' ' + imporantField1 + ' ' + > importantField2; > > getSimpleName survives refactoring and char space ' ' is 'neater' in > my mind than a white space string. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/javaposse?hl=en -~----------~----~----~----~------~----~------~--~---
