Posts

Showing posts from 2025

Does Anyone Know What Time It Is?

Image
  If you’ve ever written a unit test that failed only on Tuesdays , only after midnight , or only on CI but never locally , then congratulations — you’ve been personally victimized by DateTime.Now . Time is one of those sneaky dependencies we rarely think about… until it breaks our tests. Thankfully, modern C# finally gives us a first-class way to deal with time in a testable, civilized way: ๐Ÿ‘‰ TimeProvider Let’s talk about why it exists, why it matters, and how it makes your unit tests calmer, cleaner, and way less haunted. ๐Ÿงจ The Classic Problem: Time Is a Liar Here’s a pattern we’ve all written: public bool IsExpired ( DateTime expiresOn ) { return DateTime.Now > expiresOn; } Seems harmless, right? Now try to unit test it. What time is it right now ? What happens if the test runs at midnight? What about daylight saving time? What if the test is slow? What if it runs in a different time zone? You don’t control time — time controls you . ๐Ÿง  Enter: TimePr...

Modernize Your Code, Modernize Your Thinking

Image
  Why “One Class per File” Is Outdated—and What Modern C# Developers Should Do Instead For decades, C# developers have lived by a simple rule: “One class or interface per file.” This rule was so common that many of us (myself included) never questioned it. It became part of our coding DNA—just like putting braces on their own line (hello, 2005) or creating separate IService and Service folders. But today, we’re writing code in C# 12 , designing systems with Vertical Slice Architecture , navigating code with AI-powered tools , and building applications that emphasize features , not ceremony . Yet this ancient rule still lingers. Let’s be honest: ✔ It made sense years ago. ✘ It makes far less sense today. If you want to modernize your codebase , you must begin by modernizing your mindset . Let’s dive in. ๐Ÿ›️ The Legacy of “One Class per File” This rule grew out of a different era—an era when: ✔ IDEs were primitive Early Visual Studio couldn’t n...
Image
  APIs Are More Than REST: A Practical Guide to How Software Really Talks Think for a moment about your daily digital life: You pay for coffee with your phone You check your bank balance Your smartwatch records your steps Your software talks to other software All of it works—even though none of these systems were built by the same team How? APIs. But if your first thought is “REST API, JSON, HTTP GET/POST” —you’re only seeing a small slice of the picture. APIs come in many shapes, sizes, and communication patterns. And understanding that broader landscape is one of the most valuable architectural skills we can build today. Today, let’s zoom out. ๐Ÿš€ What Is an API, Really? API stands for Application Programming Interface , but that technical name hides the real purpose: An API is a contract that lets two pieces of software communicate without needing to know how each other works. It’s about clarity. About abstraction. About independence. APIs let softwa...