Dev Diary - September 2023
Oh the plans of mice and men... I could probably start all my dev diary posts this way, but I'll go ahead and burn the phrase on this post. I had gone into this month thinking I would have a working prototype for my "No Browser" application by the end and instead have a demo app of a Baseball game represented as a finite state machine. Let me explain.
No-Browse Browser #
The month started off as planned, working on my browser app but that quickly got derailed by two things. The first was complexity working with the "WebView" component. I was running into issues ensuring I passed the correct URL to the component, managing configuration changes, and handling launching into the web view screen from an intent in an ergonomic fashion. I put the project aside to muse on the issues more and during that time I discovered an awesome screen time app called StayFree which handles setting time limits for apps AND websites. That has sufficed to solve my "browsing" problem for the moment so I turned my attention to other projects.
Wordle Clone #
As Dagger has added support for KSP and development on K2 has continued forward, I thought I would give it a try in my Wordle App. The upgrade process for both was quite easy. For KSP, I was already using KSP for Room, so all I had to do was update Dagger to the latest version, change the kapt
call to use ksp
instead, and remove the kapt plugin. Adding K2 was even easier, just add kotlin.experimental.tryK2=true
to the project gradle.properties
file and it was ready to go. If you want to play around with it, feel free to check out the GitHub repo linked above, the changes are already merged into master.
Baseball State Machine #
The last major project I worked on was building an app to simulate a simplified baseball game. I started the project using Bun.js with its wonderful WebSocket support and had started with a simple MVI style approach with actions and a reduce method. I quickly realized that the steps of the MVI flow were in the same basic sequence each time and could be better represented as a finite state machine. So I pivoted to use the XState library. While that project is still in flight, I was inspired to build a manually controlled version in Kotlin using the StateMachine library from Tinder. You can check it out in this GitHub repo and be sure to keep an eye out for a new article on the topic coming out in a few weeks.
Vision Pro #
I wrapped up the month going through some tutorial videos from WWDC on the new Vision Pro. I'm very interested to play with the technology and to learn how to build for the platform, call it a "small bet" on AR as the future of computing. I don't have any updates at the moment, but I'm really excited to learn about something new after having intensely focused on Android for the past few years. Don't worry, this blog and my project work will continue to focus on Android development for the foreseeable future.
Key Learnings #
- WebView Configuration Changes are Tricky - While working on the browser I ran into issues with configuration changes such as having to track the current URL to stay on the page and having to manually handle configuration changes in order to not reset video playback. I need to do a lot more research before I'm ready to commit to working on that issue more.
- State Machines are a nice alternative to MVI - With my experience working with React/Redux I tend to reach for MVI style architectures regularly. That's all fine and good, but after working on the baseball state machine app I now see that in several past projects I would have been better served with a state machine (the Wordle GameEngine comes to mind).
- "Dumb" UI worked really well - In last month's dev diary I mentioned being interested in exploring an approach where all screen display data was handled by the state holder. I tried this in the baseball state machine app and it worked really well! The app and screen are fairly small, but I'm on the lookout to try it again in larger scenarios.
- KSP + K2 = Faster? - In upgrading to KSP and K2, I tried to do some light benchmarking and according to the numbers it was faster, probably. I don't feel super confident with my methodology and it is hard to say with confidence how much faster it actually is. I was however turned on to the gradle-profiler library which could give me better results. I'll let you know if I find time to run it.
- Koin, DI finally - I came across the newest update to Koin (3.5.1) which adds "bom" support but more importantly Koin-Annotations (1.3.0) which adds compile time safety checks. This is really exciting because Koin's standard approach is just too close to a "Service Locator" for my taste, and trust me, I've been bit. As an added bonus, in my testing the error messages were far clearer than the often cryptic messages from Dagger/Hilt, e.g.
e: [ksp] --> Missing Definition type 'XXX.IncrementUseCase' for 'XXX.MyAppViewModel'. Fix your configuration to define type 'IncrementUseCase'
.
What's Next #
Right now I'm continuing to work through Vision Pro tutorials so my next project will be something for iOS/Vision Pro. That's looking to be an iOS version of the Bible in a Year Tracker at the moment. I'm also on the lookout for another Android project to sink my teeth into. That could be a return to my stretching meditation app I started earlier this year, or something else that strikes my fancy. At least for now the baseball project is on ice as I'm happy with the work I did on the state machine and want a break from that work.
Conclusion #
Starting this article I thought I wouldn't have a lot to talk about, and I was pleasantly surprised to be wrong. I know these dev diary posts don't get the most attention, but they are really motivating for me to keep projects in flight throughout the month. So genuinely thank you to anyone reading these posts, I hope they are helpful and inspirational to you as well. Until next time, thanks!
Did you find this content helpful?
Please share this post and be sure to subscribe to the RSS feed to be notified of all future articles!
Want to go above and beyond? Help me out by sending me $1 on Ko-fi. It goes a long way in helping run this site and keeping it advertisement free. Thank you in advance!