Playing Trombone Champ... with a Trombone
Dan Lew Codes
by Dan Lew
6M ago
Trombone Champ is a silly little rhythm game that took the world by storm last year (for approximately two weeks). The trombone is an instrument I've been playing for 25 years. As a lover of both rhythm games and trombone, of course I got Trombone Champ. Naturally, I wondered: can I control it on an actual trombone? The answer is: yes! This video isn't new; I posted it a year ago on Twitter but that site is dead to me now. This longer-form content also gives me an opportunity to better explain the mechanics behind the video. First, the trombone controller. You'd think that you could easily co ..read more
Visit website
In Search of Exploration Games
Dan Lew Codes
by Dan Lew
1y ago
(This article is spoiler-free.) In the past few years, I’ve fallen in love with exploration in video games. This mechanic is key in games like Outer Wilds or Subnautica. You’re dropped into the middle of a world and are given free reign to go anywhere, discovering many surprises along the way. I want more! However, recommendations for exploration games often include entries I’ve played yet don’t consider to be in the same genre. Breath of the Wild, Elden Ring, Death Stranding… all games I love, and while they give you much freedom, they never gave me the same sense of exploration as with Oute ..read more
Visit website
Sharing code between test modules
Dan Lew Codes
by Dan Lew
1y ago
In 2015, I wrote a post about sharing code between unit tests and instrumentation tests on Android. Iain Cunningham just pointed out that the method I outlined no longer works. That’s fine for me because I haven’t used that method in years! Nowadays I use modules, which provide a far superior method of solving the problem (and is the method Google promotes now as well). Here’s how that works: Start with a module called :library. Create a second module named :library-shared-test and put :library as a dependency of it. Implement your shared test utilities in :library-shared-test. Now, here’s th ..read more
Visit website
Domain-Specific Models
Dan Lew Codes
by Dan Lew
1y ago
For a long time at Trello Android, we used the same class for parsing API calls (via Gson), making DB transactions (via OrmLite), and displaying data in the UI. Here’s a pseudo-code-y example of a board: @DatabaseTable(tableName = "boards") data class Board( @DatabaseField(columnName = “name”) @SerializedName("BoardName") private var boardName: String?, private var cards: List<Card>?, private var lastViewedTime: Long? ) While it was allocation efficient and somewhat convenient to have all this data in one place, more often it was just a pain in the ass: Availability sadness ..read more
Visit website
Maintaining Software Correctness
Dan Lew Codes
by Dan Lew
1y ago
This article is a write-up of a talk I gave at MinneBar 2022. You can see the slides for the original deck here. (As of writing, the recording is not online yet.) The title of this talk is "maintaining software correctness." But what exactly do I mean by “correctness”? Let me set the scene with an example. Years ago, when Trello Android adopted RxJava, we also adopted a memory leak problem. Before RxJava, we might have, say, a button and a click listener; when that button would go away so would its click listener. But with RxJava, we now have a button click stream and a subscription, and that ..read more
Visit website
Year in Review (2021)
Dan Lew Codes
by Dan Lew
2y ago
I continue to do less and less each year due to the dual woes of raising a toddler and navigating a pandemic. I also took three months off work this summer and I didn't much feel like doing anything tech then! I suspect that 2022 won't be much more productive, but maybe in 2023 (when my toddler has aged out of being a toddler, and COVID is hopefully less in our minds) I'll start picking things back up again. Articles A Warning Regarding Android App Startup with Multiprocess Apps A small note on a niche problem. I write these posts in the hopes that someday someone else will save a bit of tim ..read more
Visit website
How Trello Android converted from Gson to Moshi
Dan Lew Codes
by Dan Lew
2y ago
Trello Android recently converted from using Gson to Moshi for handling JSON. It was a bit tricky so I wanted to document the process. (For context, Trello Android primarily parses JSON. We rarely serialize JSON, and thus most of the focus here is on deserializing.) Why Refactor? There were three main reasons for the switch from Gson to Moshi: safety, speed, and bad life choices. Safety - Gson does not understand Kotlin’s null safety and will happily place null values into non-null properties. Also, default values only sometimes work (depending on the constructor setup). Speed - Plenty of benc ..read more
Visit website
My Programming Earworms
Dan Lew Codes
by Dan Lew
2y ago
There are tons of articles online that discuss the articles/talks/books that you must consume to become a true programmer. I dislike this framing; it’s gatekeeping, plus software development is such a varied discipline that one person’s essential reading is entirely unnecessary for another. Instead, I’d like to present to you my programming earworms. An earworm is a song that gets stuck in your head and just keeps popping up at random times. Likewise, the following are articles/talks/books I consumed years ago yet somehow keep coming back to mind, over and over, because they really struck a ne ..read more
Visit website
Edina School Board Election (2021)
Dan Lew Codes
by Dan Lew
2y ago
Here’s my thinking around this year’s Edina school board elections. The short version is that I’m voting for Erica Allenburg, Dan Arom, Michael Birdman, and Karen Gabler, but read on for more details. The Edina school board is composed of seven (non-partisan) members. Each member serves a four-year term. These terms overlap such that there are either three or four seats to fill every two years. Election day is November 2nd, or you can vote early at city hall, or vote by mail. This year there are six candidates running for four seats: Erica Allenburg (incumbent) Dan Arom Michael Birdman Karen ..read more
Visit website
The dangers of JSON + default values
Dan Lew Codes
by Dan Lew
3y ago
The following code converts an object to JSON and then back again: val adapter = Moshi.Builder().build().adapter(Foo::class.java) val foo = Foo(bar = null) val json = adapter.toJson(foo) val foo2 = adapter.fromJson(json) check(foo == foo2) I think most of us would expect check() to pass, but there's actually one circumstance where it will fail: a nullable field with a non-null default value. data class Foo(val bar: String? = "oops") Because we're mixing nullability + non-null default values... toJson(Foo(null)) == "{}" because there's no reason to put a null bar in the output. fromJson ..read more
Visit website

Follow Dan Lew Codes on FeedSpot

Continue with Google
Continue with Apple
OR