Closed veyndan closed 6 years ago
unsubscribe.
On Tue, Feb 6, 2018 at 8:25 AM, Veyndan Stuart notifications@github.com wrote:
I converted some trivial models (i.e. ones with basic accessors and/or not inner classes) to Kotlin. As this is a bit of a showcase of the benefits of Kotlin, there are a few things which just doing this has added:
- All the fields are encapsulated (which wasn't the case in CommitMatch.java).
- Automatic derivation of toString() (along with some other methods) which makes logging for debugging easier.
- Classes are closed by default. There is a lot of inheritance in this app which sometimes baffles me, and to have the assurance that this is not the case semantically is good.
- No properties can be null and this is enforced by the compiler. Again, this assurance makes it easier to reason about the state in which the model is in.
- Reduction in verbosity which by looking at the change in LoC speaks for itself.
Note: I did remove some documentation that I felt was uneccessary e.g. getGist() documented as @return gist.
You can view, comment on, or merge this pull request online at:
https://github.com/pockethub/PocketHub/pull/1155 Commit Summary
- Add Kotlin support
- Convert trivial models to Kotlin
File Changes
- M app/build.gradle https://github.com/pockethub/PocketHub/pull/1155/files#diff-0 (5)
- R app/src/main/java/com/github/pockethub/android/core/commit/ CommitMatch.kt https://github.com/pockethub/PocketHub/pull/1155/files#diff-1 (31)
- D app/src/main/java/com/github/pockethub/android/core/gist/ FullGist.java https://github.com/pockethub/PocketHub/pull/1155/files#diff-2 (65)
- A app/src/main/java/com/github/pockethub/android/core/gist/ FullGist.kt https://github.com/pockethub/PocketHub/pull/1155/files#diff-3 (24)
- D app/src/main/java/com/github/pockethub/android/core/issue/ FullIssue.java https://github.com/pockethub/PocketHub/pull/1155/files#diff-4 (66)
- A app/src/main/java/com/github/pockethub/android/core/issue/ FullIssue.kt https://github.com/pockethub/PocketHub/pull/1155/files#diff-5 (25)
- M app/src/main/java/com/github/pockethub/android/ui/gist/ GistFragment.java https://github.com/pockethub/PocketHub/pull/1155/files#diff-6 (2)
- M app/src/main/java/com/github/pockethub/android/ui/user/ UriLauncherActivity.java https://github.com/pockethub/PocketHub/pull/1155/files#diff-7 (2)
- M build.gradle https://github.com/pockethub/PocketHub/pull/1155/files#diff-8 (2)
Patch Links:
- https://github.com/pockethub/PocketHub/pull/1155.patch
- https://github.com/pockethub/PocketHub/pull/1155.diff
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/pockethub/PocketHub/pull/1155, or mute the thread https://github.com/notifications/unsubscribe-auth/AKYHFLRLbUPzLkwdbwRPEgi_TxBg3H8aks5tR5vqgaJpZM4R6Txz .
I converted some trivial models (i.e. ones with basic accessors and/or not inner classes) to Kotlin. As this is a bit of a showcase of the benefits of Kotlin, there are a few things which just doing this has added:
CommitMatch.java
).toString()
(along with some other methods) which makes logging for debugging easier.null
and this is enforced by the compiler. Again, this assurance makes it easier to reason about the state in which the model is in.Note: I did remove some documentation that I felt was uneccessary e.g.
getGist()
documented as@return gist
.