Why your code is hard to test (and how to fix it) | Issue #81


If your code is hard to test, hard to reuse, and hard to change, you’re probably hardcoding your dependencies.

It’s one of the most common architectural problems I see in Python code, even in production systems.

In this week's video, I take a small but realistic example, a data pipeline that loads, transforms, and exports some records, and show you how Dependency Injection can turn it from a rigid mess into something clean, testable, and modular.

No frameworks required.

You’ll learn:

  • Why hardcoded logic breaks your codebase
  • How to refactor to constructor-based DI
  • How to write your own tiny DI container (in just a few lines)
  • And how frameworks like FastAPI use DI under the hood


Enjoy your weekend (and don't forget to check out the insane Black Friday offer below 😉)!

Cheers,

Arjan


🔥 Happy Black Friday! 🔥

It’s that time of year again: I’m rolling out the BIGGEST discount of 2025 on all ArjanCodes courses! For just a few days, you can grab any course at 30% off.

If you’re ready to start thinking like a software architect, sharpen your design skills, and finally invest in the kind of high-level thinking AI can’t automate, now’s the perfect moment.

Here’s what you can dive into:

Just use coupon BLACKFRIDAY2025 at checkout.

⏳ Don’t wait: this offer disappears on December 1 at midnight!

👕 Clean code and clean clothes

The ArjanCodes merch store features T-shirts, hoodies, hats, and more for the clean-code-obsessed. Careful though: you'll look dangerously professional while reviewing PRs.

👉 Check out the store here and grab something before your stand-up call starts.

Unsubscribe | Send by ArjanCodes

Wolvenplein 25, Utrecht, UT 3512 CK

The Friday Loop

Every Friday, you'll get a recap of the most important and exciting Python and coding news. The Friday Loop also keeps everyone posted on new ArjanCodes courses and any limited offers coming up.

Read more from The Friday Loop

AI can write code now. But you already knew that :). If you’ve tried using AI seriously, you’ve probably noticed something: the code works (kind of) and then slowly turns into a mess. In this week’s video, I show why prompting alone isn’t enough and why software design is becoming more important, not less, in an AI-driven world. I walk through a real interaction with an AI coding assistant and show how thinking in terms of responsibilities, structure, and system boundaries completely changes...

In a recent video on refactoring complicated business logic, I managed to introduce several subtle errors. Many of you immediately spotted them in the comments. That’s exactly what my first video in 2026 is about. I walk through the mistakes I made, explain why they happened, and show how easy it is to accidentally change behavior when you refactor code. Even with tests in place and decent coverage, assumptions can sneak in, business rules can shift, and logic can quietly break without anyone...

You’ve tested the endpoint. The response looks right. No errors in the terminal. So you’re done, right? Well... not quite. In the last video of this year (time flies!) I start with a tiny FastAPI app that "works", and step by step, I turn it into something that’s actually ready for production (and that's more work than you think). That includes: Proper type usage Input validation and error handling Configuration management Rate limiting to prevent abuse ...and more! All using a real example:...