So I fell behind a bit with my project to learn Test Driven Development using C++ based on the book by Jeff Langr. On top of I have taken a brief involuntary break from my "couch to 5 km" journey.
In my defence, both of these are due to getting a stomach bug that left me bedridden for 2 days and living in an active war-zone that involves hundreds of ballistic missiles being launched at my country.
The Dependency Rabbit-Hole
Anyway, onwards and upwards - as they say. To get my coding journey back on track I started following a course on YouTube on how to create a VPN client for Flutter. First thing I needed to do was update my version of the Flutter SDK - it was quite old. This set off another cascade of issues that reminded me of the risks of relying on a framework.
In order to upgrade Flutter SDK - I needed to upgrade Android. Perhaps because I was trying to upgrade my 3rd party dependencies at 11pm I thought that I did not have Android installed. Turns out it was - but by now my setup was broken through my own actions.
Fast forward to the next evening and I immediately upgraded Android Studio. This fixed the crash with the Flutter upgrade. The next step was to check if flutter doctor command worked OK... it didn't. It crashed but with a helpful breadcrumb message of how to fix the issue. I just needed to update flutter with the location of my Android SDK. Which as you may have guessed I did not know.
Some Googling later and it turns out that my Android SDK location is quite simply:
/home/<user name>/Android/Sdk
In order to update it in Flutter, I used the following command:
flutter config --android-studio-dir="/home/<user name>/Android/Sdk"
And finally... Flutter doctor was able to run to completion (even though some errors remain).
flutter doctor -v
Finally I thought that my problems were all over. However, opening up VS Code and trying to run an old project failed. So after upgrading packages in the terminal with:
flutter pub upgrade --major-versions
And now I am stuck on this error:
You are applying Flutter's app_plugin_loader Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future release. Migrate to applying Gradle plugins with the declarative plugins block: https://flutter.dev/to/flutter-gradle-plugin-apply
And that is where I am leaving it for now. I will fix this issue tomorrow night. In the mean-time the main take-away is that managing dependencies is hard, perseverance and refining Google queries are essential skills, and know when to take a break.
TDD Is a Misnomer
Coming back to the reading project about Modern C++ Programming with Test-Driven Development Code Better, Sleep Better by Jeff Langr - the following paragraph really struck a chord. I'm not sure that I like the name test driven development, it does not accurately describe what the aim of the practise is. This extract confirms this belief:
4.6 Testing vs. Test-Driving: Parameterized tests and Other Toys
Despite the work test appearing in it's name, TDD is less about testing that it is about design. Yes, you can produce unit tests as a result of practicing TDD, but they are almost a by-product. It might seem like a subtle difference, but the true goal is to allow you to keep the design clean over time so that you may introduce new behavior or change existing behavior with high confidence and reasonable cost.
I'm still part way through the book and after chapter 2, the book is less hands-on and more theory. Having tried some of the early chapter information - I will do another project soon that applies some of the knowledge gained from chapters 3 to 5.
EDIT: (10-Oct-2024): The issue was with the Flutter plugin for VS code. By using "flutter create <app_name" on the command line and opening the project folder in VS Code - I was able to build the APK and run the app.
No comments:
Post a Comment