@Override
public String toString() {
return new Gson().toJson(this);
}
Am I breaking some good practice, "Joshua"-pattern thing, general design pattern or other convention by simply doing this as default behavior for my model objects?
toString()
will anyhow only be used in debugging in the paradigm (Android) that we are currently using. That's also the reason why I like seeing the object in JSON since much ORM/json persistence will be happening through http->php/python->mysql and to the local SQLite.
toString()
can return any String (but it should probably return the same String every time you call it on the same instance, unless the internal state of the instance changes).