-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor NavigationRequest object
to data object
#2391
base: master
Are you sure you want to change the base?
Conversation
/gcbrun |
@yongsuk44 Can you please fix the failing build? |
@shobhitagarwal1612 |
data object NavigateUp : NavigationRequest | ||
|
||
data class NavigateTo(val directions: NavDirections) : NavigationRequest | ||
data object FinishApp : NavigationRequest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the rational behind changing it from object
to data object
? other than data object
gives you the power to have a toString() function as written in the PR description, which just prints the name of the object
looks like an extra work we are trying to give to compiler to generate some functions for us, which we are currently not using.
WDYT?
Let me know if I am missing anything here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also adds more boilerplate it seems in referencing code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the comment. 😀
@anandwana001
The functions generated by the data object
, such as toString()
, may not be used in production code, but they can be useful for debugging during development. This can be easily understood through a link.
Also, Requesting additional work from the compiler is also justified because the Kotlin compiler is optimized to handle methods like toString
, equals
, and hashCode
(e.g., for data classes).
@gino-m
I understand that this leads to some additional boilerplate, but I think it has improved readability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got the idea now, cool, let's have it.
Running integration tests, they should complete shortly: /gcbrun |
'data object' instead of a plain 'object' means that it automatically has a 'toString()' function without the need to override it manually
Link