Sitemap
Level Up Coding

Coding tutorials and news. The developer homepage gitconnected.com && skilled.dev && levelup.dev

Member-only story

Extension Object Pattern in .NET C#: From GetExtension to feature collections (2026)

--

Imagine developing the order module of an e-commerce site. The Order class lives in the core of the system, and checkout, warehouse and invoicing all depend on it. Then, in the same quarter, three teams knock at the door: the gift team wants a wrapping and a greeting card, the B2B team wants the VAT number and the code for electronic invoicing, the international shipping team wants the customs code and the declared value. The fastest answer is to open Order and add everything:

// Naive approach - What NOT to do
public class Order
{
public Guid Id { get; init; } = Guid.NewGuid();
public required string CustomerName { get; init; }
public List<OrderLine> Lines { get; } = [];

// Gift wrapping module
public bool IsGift { get; set; }
public string? GiftMessage { get; set; }

// B2B module
public string? VatNumber { get; set; }
public string? EInvoiceCode { get; set; }

// International shipping module
public string? HsCode { get; set; }
public decimal? DeclaredCustomsValue { get; set; }

// ... and tomorrow the marketplace team asks for SellerId
}

Every module makes the core class grow, every order carries every field (most of them null), and every change needs a new release of the package everybody depends on. Worst of all, the core now knows about customs codes and greeting cards.

This is exactly the kind of problem the Extension Object pattern was born to solve…

--

--

Emanuele Longo
Emanuele Longo

Written by Emanuele Longo

.NET Software Developer driven by clean architecture and purposeful design.