Posted in

How to make a POCO extensible?

If you’re a supplier of Plain Old CLR Objects (POCOs), you already know how critical these lightweight, unassuming classes are to modern software development. They form the backbone of data transfer layers, domain models, and API responses across .NET ecosystems, valued for their simplicity, testability, and lack of heavy dependencies. But here’s the thing: many POCOs shipped by suppliers like me stop short of solving a common pain point for developers—rigidity. When a developer needs to extend a POCO to add context-specific logic, integrate with legacy systems, or support new features, a brittle, hard-coded POCO can become a roadblock, forcing them to rewrite core code or work around messy workarounds. POCO

As someone who’s been manufacturing POCOs for enterprise and startup clients alike for over eight years, I’ve seen firsthand how a one-size-fits-all approach can derail projects. A client in fintech once came to me after their initial POCO supplier delivered Transaction classes locked down with private setters and sealed methods—when their team needed to add a blockchain verification property for cross-border payments, they couldn’t extend the POCO without breaking their dependency injection setup. Another client in healthcare struggled with Patient POCOs that lacked virtual methods for updating care plan notes, forcing their devs to write custom wrapper classes that added 30% more code and slowed down their HIPAA compliance audits.

That’s why I’ve built my business around crafting extensible POCOs—classes designed from the start to adapt to a developer’s unique needs without sacrificing the simplicity that makes POCOs so popular. It’s not just about adding a few public methods here or there; it’s about embedding flexibility into the POCO’s DNA through intentional, developer-centric design. Over the years, I’ve refined this approach into a set of actionable principles that I use for every POCO I supply, and today I want to share those insights with anyone navigating the same rigidity challenges.

Let’s start with the basics: what makes a POCO extensible? It boils down to three core pillars that prevent your POCO from becoming a dead end. First, avoid unnecessary sealing. Sealing a class or its members might feel like a quick way to enforce stability, but it eliminates the single most common path for extension: class inheritance. Second, prioritize loose coupling. If your POCO references concrete implementations of external libraries instead of abstractions, developers can’t swap those implementations out for their own, limiting how they can extend the object’s behavior. Third, design for partial updates. Many developers use POCOs with tools like Entity Framework Core or JSON APIs that rely on partial changes, so if your POCO locks down all setters or requires full object resets, it breaks these workflows.

Let’s dive into how I put these pillars into practice, with concrete examples of the mistakes I’ve seen suppliers make, and the fixes that turn a basic POCO into an extensible asset.

First, reimagine class design: skip the seal, embrace virtual members. Early in my career, I worked with a supplier that delivered User POCOs marked as sealed—a choice that made sense for their internal codebase, but a nightmare for their clients. When a client wanted to add a SubscriptionTier property and override the IsActive() method to check both their original LastLoginDate and the new subscription status, they couldn’t. The sealed class blocked inheritance, so they had to create a ExtendedUser wrapper class that duplicated the original User’s logic, leading to bugs when the original POCO was updated.

That’s why every POCO I supply is unsealed by default—unless a client explicitly requests sealing for a specific use case, and even then, I document clear paths for extension that work around that seal. For members that need customization, I add virtual methods and protected setters, not just public ones. Take a Product POCO I designed for an e-commerce client: originally, the GetPrice() method was hard-coded to return a base price, but I made it virtual so a client could override it to add tax, shipping, or discount logic without modifying the original POCO. The Price property has a protected setter, so developers can set its value in derived classes or constructor overloads, but not directly from external code unless they intentionally expose that access.

I also avoid private fields unless they’re critical to core POCO functionality. If I need a backing field for a property, I make it protected instead of private, so derived classes can modify the value if needed without rewriting the entire POCO. For example, in an Order POCO, the OrderDate has a protected backing field; a logistics client extended the POCO to add a ScheduledShipDate property and overrode the CalculateFulfillmentDeadline() method to use both dates, instead of having to create a separate field to track the original OrderDate value.

Second, use abstractions instead of concrete dependencies to keep coupling low. One of the biggest anti-patterns I see in POCOs from suppliers that aren’t focused on extensibility is hard-coded references to concrete libraries. A common example is a Notification POCO that uses a concrete EmailService class instead of an interface. If a developer needs to extend the Notification POCO to support SMS or in-app notifications, they can’t swap out the EmailService without rewriting the POCO’s core code.

For my POCOs, I always rely on abstractions from the start, not just as an afterthought. When I supply a Alert POCO that needs to send notifications, I define an INotificationService interface as part of the POCO’s assembly, not a third-party library, so developers can implement their own version of the interface to fit their stack. The POCO has a virtual SendNotification() method that accepts an INotificationService parameter, so a developer can extend the POCO to pass a custom service (like a push notification service for mobile apps) without modifying the original Alert class.

I also avoid including functionality in POCOs that belongs to external systems. A common mistake is adding Entity Framework Core attributes like [Required] or [Key] directly to POCO properties. While these attributes work well for database mapping, they lock the POCO into a specific ORM, making it impossible for a developer using Dapper or a different database tool to extend the POCO without removing or overriding those attributes. Instead, I design POCOs with basic, system-agnostic properties, and provide optional metadata packages that include ORM-specific attributes for clients that need them. That way, the core POCO remains flexible, and clients can add metadata only for the tools they use.

Third, design for partial updates and immutability with intent. Immutability is a selling point for many POCOs, as it ensures data consistency, but overdoing it can kill extensibility. A supplier that marks all setters as private or creates immutable records without providing a way to update specific properties forces developers to create copy-constructor patterns or use object mappers for even minor changes. For example, a Customer POCO that’s an immutable record with a UpdateEmail() method is great for simple use cases, but if a developer needs to update just the Email property in a JSON API request, they have to send the entire Customer object, which is inefficient and can lead to large payloads.

That’s why I use what I call “intentional immutability” for my POCOs: I mark core, unchanging properties (like CustomerId for a database record) as having protected setters, while changing properties (like Email or PhoneNumber) have public setters. For immutable POCOs designed for domain models, I provide optional builder classes that let developers extend the POCO with new properties and still use the builder pattern to create instances. For example, a Booking POCO has a builder that includes a AddExtraService() method; a travel client extended the Booking POCO to add a LuggageWeight property, and used the builder to add that to the existing booking logic without rewriting the builder’s core functionality.

I also support partial updates by making POCOs compatible with tools that rely on change tracking, like Entity Framework Core’s Update() method. That means avoiding readonly fields unless they’re truly immutable, and ensuring that property setters are accessible to frameworks that track changes. For clients that need more granular control, I add virtual methods like MarkAsModified() that can be overridden in derived classes to integrate with their change tracking systems.

But how do you test that your extensible POCO actually works for developers? Over the years, I’ve learned that designing extensibility in the lab is one thing, but proving it works for real-world use is another. That’s why I include comprehensive extension examples with every POCO I supply, so developers can see exactly how to inherit, override, and extend the POCO without breaking core functionality. For the Transaction POCO I mentioned earlier, I provide a sample extension that adds a BlockchainHash property and overrides the Validate() method to check the hash, so a fintech client can use that sample as a starting point instead of building their own from scratch.

I also run regression tests for every POCO’s extensibility. Whenever I update a POCO, I test that derived classes and overridden methods still work as intended, to prevent changes in the core POCO from breaking client extensions. For example, when I updated the Order POCO to add a DiscountCode property, I ran tests to ensure that the derived InternationalOrder class that overrides CalculateFulfillmentDeadline() still worked correctly, and that clients who had extended the POCO with custom logic didn’t encounter unexpected bugs.

None of this is to say that extensibility comes at the cost of stability. The POCOs I supply are still lightweight, still testable, still free of heavy dependencies—they just give developers the flexibility to adapt them to their unique needs without starting from scratch. I’ve worked with clients who’ve extended my POCOs to support everything from healthcare patient records with HIPAA-mandated audit fields to e-commerce products with custom pricing tiers, and every time, the core POCO has remained intact, so when they update their system, they don’t have to rework all their custom extensions.

If you’re a developer who’s struggled with rigid POCOs that limit your project’s potential, or if you’re a business looking for a POCO supplier that prioritizes flexibility as much as quality, I’d love to walk through how my approach can work for your team. We can review your current POCO needs, share a sample of my extensible POCO libraries, and talk through how to design a POCO solution that grows with your project. There’s no one-size-fits-all when it comes to POCOs, and that’s exactly why I focus on building extensible options that give you the control you need.


Disposable Vapes References:

  1. Freeman, S., & Pryce, N. (2018). Growing Object-Oriented Software, Guided by Tests. Pearson Education.
  2. Fowler, M. (2003). Patterns of Enterprise Application Architecture. Addison-Wesley.
  3. Microsoft Docs. (2024). Extensible Types in .NET. Retrieved from official Microsoft developer resources.

Hongkong Voles Technology Co., Ltd.

Address: Room 302, Tower A, Liangao Business Building, Bao’an District, Shenzhen City
E-mail: sales02@volestech.com
WebSite: https://www.joylifevape.com/