knowm / XChange

XChange is a Java library providing a streamlined API for interacting with 60+ Bitcoin and Altcoin exchanges providing a consistent interface for trading and accessing market data.
http://knowm.org/open-source/xchange/
MIT License
3.87k stars 1.94k forks source link

toString conventions #2966

Open walec51 opened 5 years ago

walec51 commented 5 years ago

Do we relay need those toString boilercode for DTOs? For me their result is usually to long to use in debugging / logging so I end up using the debuggers UI to introspect the object anyway.

Personally I'm in favor of only using toString when a short text representation makes sense.

Like in CurrencyPair where toString results in "BTC/USD".

For more complex object where such a representation is not apparent we can do one of the following:

  1. just stop adding boilercode generating by the IDE
  2. use Lombok
  3. use a one liner with our ObjectMapperHelper in toString to just serialize the object to JSON
makarid commented 5 years ago

How can we do the 3?

nielsdraaisma commented 5 years ago

As much as I dislike boilerplate, the other options have downsides as well.

2) As funky as Lombok looks at times it does has its issues when JVM versions changes, it more a hack than anything. If anything embracing a different compiler like kotlin and it's data classes would not have that problem.