Legacy code and Test Driven Development (Part 2)

Yesterday, I wrote about legacy code and how it really was not possible to initially do test driven development, aka TDD. In this post, I will detail a strategy which I feel is good at explaining how to go about testing. I make no guarantees that this is the best way to go about it (please feel free to suggest other tricks you might use), but it works. But these are useful for me in porting Medusa V2 code to Medusa V4 (long story about why not V3, but there are reasons).

Legacy code and Test Driven Development

I am sure many of us have faced the task of trying to do test driven development (TDD) on a legacy codebase. I myself am facing such a challenge, with several tens of thousands of lines of code in a Laravel project which I am helping maintain and is around a decade old. And being severely behind in the packages it uses, the time has come to give the code some TLC, and update it to use the most recent versions of those package (for example, we are moving from Laravel 5 to 12).

Major Drupal upgrade and a new theme

I just spent the day (and then some) upgrading both the development version of this site and this site, and it has not been a fun upgrade. Part of the problem was that I had to switch themes, as the d8_blog_theme has apparently stopped being maintained. But thanks to my friend Dave, who does Drupal professionally, he cloned the repo and did some fixes in addition to making it compatible with Drupal 11.

Another WTF Chrome...

Why is it that periodically, I try to connect to my web server, which has a private IP address in my network, and I find that I have to go back into Chrome's settings, turn on secure DNS and turn it back off???  Grrr...

Fluent interfaces and method chaining: A potential hidden landmine

Of late, I have been doing some maintenance work on a legacy website which uses Laravel and PHP 7 (work on the upgrade is in progress). In testing, we found a situation where we were trying to call a method on a NULL value. The line of code read as follows:

      $fleet = Chapter::find($this->getAssignedShip())->getAssignedFleet(true);

The code would then go on to properly use the $fleet value, checking for whether or not it was NULL before using it.

Why I hate Windows

While I use Windows on a limited basis, I generally have a hate-hate relationship with it. My transition from an old Dell laptop running Windows 10 (which was out of warranty and having the fans fail) to a new one running Windows 11 hit several of my buttons in this relationship, which I will touch upon here today, in roughly the order I encountered them. And all this is beyond the whole $$ for functionality mindset.

Incomplete/Incorrect demos

I recently have been trying to work up a side project using Laravel to download and display the information from my YouTube video playlists, using an API which requires OAuth2 authentication. The last time I played with something like this was years ago, and they only required an application key, not the full blown login.

Heimdallr... crossing the rainbow bridge.

In my last post, I talked about running into limitations with Django and Python, where I had queries I was wanting to do, but the integration between the RawQuerySets and DRF were blocking me from being able to easily build those queries and route the results to the DataTable.. Well,  I spent a day or two this past weekend recreating the entirety of what I had written in Django and Python  using Laravel and PHP, and I have some observations.

Heimdallr, do we have a bridge to cross?

When I first wrote about Heimdallr, I saw it as a project which was going to be written in Python using Django. I have been using both PHP and Python since their initial releases, but something made that pairing stand out.  First, outside of it using colons with indention to indicate code blocks, I have liked the ecosystem with stronger typing like C/C++, whereas PHP was weaker in its typing.