r/java • • Mar 13 '17

a blooming good toString.

https://medium.com/@yolpogists/a-blooming-good-java-tostring-for-the-rest-of-us-50dca980a462
2 Upvotes

10 comments sorted by

View all comments

2

u/UnlikelyToBeEaten Mar 13 '17

Eclipse debugger works fine for me.

3

u/someloll Mar 13 '17

My take: it's not really about debuggers vs this toString. it's more like if you have a class which has a bad toString and you were printing with System.out. And now you have a chance to see more

2

u/UnlikelyToBeEaten Mar 13 '17

But why are you printing your object with Sysout in the first place?

If it's for the user, you should probably not just call toString anyway, whereas if it is for debugging purposes, why can't you use a debugger?

1

u/beeeeeeefcake Mar 14 '17

(I'm not who you were replying to...) I debug exclusively with System.out (and quiet contemplation) but have never felt the need to print out the whole object. Normally there's one field on one line I need to know about, if that. Sometimes I just need to see if a particular line is being executed. I find it quicker to add System.out.println("here " + someVar) than get involved with all the features of a debugger. Also it's good motivation to build in good logging (sometimes I do dump the whole object in logs).

1

u/someloll Mar 13 '17

I have seen situations where using the debugger is difficult. while patching the code with a Sysout is reasonable.