Scale Forem

Scale YouTube
Scale YouTube

Posted on

CodeOpinion: You Don’t Need an Interface for Everything

You Don’t Need an Interface for Everything

Most of us have fallen into the habit of creating things like IOrderService or IEmailService even when there’s only one implementation—and, spoiler alert, it usually adds zero value. The video digs into why this overuse stems from how .NET Dependency Injection is taught and points out that interfaces only really shine when you need multiple interchangeable implementations or when you’re abstracting third-party APIs.

Instead of a needless interface, you can often reach for simpler tools: use a delegate for single-method callbacks, override virtual methods in a base class, or just inject the concrete type directly. The demo sections (Delegate, Override, Comments) show you how to keep your code clean and skip the boilerplate whenever an interface isn’t pulling its weight.

Watch on YouTube

Top comments (0)