Codebase Improvements
See original GitHub issueI have some general suggestions (that I’m willing to put into practice via PRs) for improving FlorisBoard’s codebase. These include:
- Cleaning up existing dependencies (some deps are unnecessary, for example, such as stdlib-jre7)
- Using kotlinx-serialization instead of moshi (smaller runtime size, slightly faster, and no reliance on reflection)
- Using Kotlin Gradle build scripts rather than Groovy build scripts and cleaning up build logic
- Storing source files at source root rather than within single-nested subpackages (i.e.
src/main/kotlin/App.kt
rather thansrc/main/java/dev/patrickgold/florisboard/App.kt
)
This list isn’t exhaustive-- there are other things that could be done too. As these are rather major changes, I wanted to seek approval first.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Case Study – Housekeeping and Codebase Improvements ...
Our startup develops artificial intelligence to help with such modeling and automate many routine tasks. Our AI already detects separate objects ...
Read more >Tips For Improving a Large Code Base With A Small Team
But when faced with limited resources, it's important to prioritize, and understanding the cost of maintaining certain improvements is part of ...
Read more >What my team and I learned when improving code quality in ...
In this article, we present a list of learnings and a general process for you to achieve a better code quality based on...
Read more >Improvements since Codebase 4
Additions and improvements. There have been hundreds of improvements since Codebase version 4. The following are the most important: ...
Read more >UI improvements to Codebase
Side-by-side diffs · Syntax highlighting within diffs · Improvements to our code review interfaces · Ability to restrict which IP addresses can ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Even the Gson maintainers don’t like Gson! It’s pretty awful. Moshi is a good runner-up, but it still does things mostly Java-style. kotlinx-serialization was pretty awkward to use pre-1.0, but the latest version is actually quite nice and reasonable to use so long as the code is architected for it. Plus, it has the benefit of using zero reflection, so the runtime is pretty light (about half the size of Moshi), and it’s a bit faster in deserialization (though not by a whole lot).
Initial from-scratch compilation with
build.gradle.kts
is generally slower thanbuild.gradle
, as Gradle has to cache a compiled version of the script (in my testing, the overall fresh build time goes from 27s to 32s for this project). Build time overall after the script compilation has been cached is generally the same. As for syntax, it was originally pretty obnoxious, but it’s improved with time-- most commonly used libraries and plugins now have first-class support for thegradle.kts
syntax. Here’s what the current configurations would look like when converted to an idiomaticgradle.kts
syntax:build.gradle.kts
settings.gradle.kts
app/build.gradle.kts
In my opinion, the main benefit of the kts syntax is significantly better IDE support and a much more declarative method of writing build scripts. The initial compilation speed is also being addressed with the new Kotlin compiler and additional caching measures-- Gradle 6.8 introduces compilation avoidance based on the classpath ABI, for example.
This is fair-- while the root convention is the one recommended by JetBrains, it also goes against the conventions that Java has held for a long time.
I’d still advocate for using the
kotlin.Result
class anyway; to me, the reduction of dependency count is worth the minor change in syntax, considering how little theResult
class is used in FlorisBoard’s codebase as is. That said, if I do submit a pull request for swappingkotlin-result
forkotlin.Result
, it’ll be separate from the main PR so you have the ability to reject it without rejecting all other changes along with it.