Dec 2, 2026
Extension Points as the Enemy of DDD and Mid-Platforms
Starting from the open-closed principle, why extension points become the enemy of DDD and mid-platforms: their impact on domain models, their difficulty to trace in call chains, and how extension implementations rot — plus control strategies across the framework, design pattern, capability orchestration, domain design, and implementation dimensions.
1. Background
DDD and mid-platforms essentially aim to reuse existing business capabilities, empower new businesses, but in most cases, DDD or a mid-platform cannot handle extremely large-scale business applications like some of Alibaba’s mid-platform applications. ByteDance is also following a mid-platform construction approach. However, regardless of this, the size of the mid-platform is still related to the company’s organizational structure. The scale of the mid-platform can be controlled by senior executives and their underlying organizational forces. Recently, ByteDance has been splitting up its mid-platform along business groups. Nevertheless, a mid-platform represents large centralized systems, making it very heavy.
After discussing so much, let’s explore why a mid-platform becomes so heavy. One important trigger for this is extension points in business. Why does DDD come into play here? Because there is a conceptual and theoretical overlap between DDD and mid-platforms. The strategic model of DDD also focuses on how to better manage large-scale business systems from an organizational perspective. So, how does the tactical model of DDD solve the problems brought by extension points in business? This is worth exploring.
2. Explanation of Extension Points
2.1 What are Extension Points?
Commonly defined as a design principle derived from design patterns: Open/Closed Principle. In essence, it means that modifications should be closed to changes while extensions should be open for modification. In the C# and Java language ecosystem, modifications refer to changes in classes and interfaces, whereas extensions refer to the expansion of abstract classes and interfaces. An extension point at module level is a high cohesion within the module with low coupling to other modules, and it supports extensibility.
2.2 Complexity of Extension Points
We can carefully examine this statement in the context of extension points. “Closed for modification” means that existing capabilities and applications should remain unchanged to minimize the cost of regression testing when modifying code. “Open for extension” refers to extending new business application capabilities through domain models expressed by the domain. Thus, here, extension points have been elevated from a code level to module and application levels. Of course, as extension points grow in size, they become harder to understand but easier to extend.
2.3 Why Extension Points Become Enemies
- Impact on Domain Models and Services
- Coupling of the Middleware’s Own Capabilities with Extension Points
- Difficulties in Tracing Issues in Chain Calls Involving Extension Points
- Management of Numerous Extension Points Becomes Unconvenient
- Implementation Schemes for Extension Points Are Not Reasonable, Making Code Harder to Maintain
2.4 Case Studies of Extension Points from a Design Perspective
Here we will use some real-life examples to experience the capabilities of extension points.
- Apple’s Dock
- Protocol Extensions in Networking
- Framework Capability Extensions
- Open-Host Service Model
2.5 Extension Points at the Architecture Level
Let’s discuss two levels of expansion at the architecture level. First, we recall DDD’s classic layered architecture: four-layer diagram:

This architectural diagram is simplified and does not strictly follow a layered model but rather a loosely layered one. Of course, it’s not overly loose.
It’s easy to think of expanding at the application layer; another expandable level would be the domain layer.
So if we look at extension points from DDD’s overall layered architecture, they are similar to the following architectural diagram:

2.6 Expansion at the Application Level
Here we will look at expansion at the application level. First, let’s understand what application-level expansion means. When our domain model or domain capabilities can fully support new business scenarios but are not explicitly expressed in the application layer, we need to iterate and update the business logic in the application layer. Here, I’ll use a case from my company’s core transaction project for refunds as an example. To clearly express the scenario of application-level expansion, I’ve drawn a simple architecture diagram of the core transaction system:

The refund capability in the domain layer covers three scenarios; however, due to different business packages, each business line needs to express its required capabilities in the adaptation layer or application package. Therefore, when Business Line C needs to access other refund scenarios (e.g., original route refunds), it can simply implement this in the application package.
2.7 Expansion at the Domain Level
In most cases, we generally do not expand at the domain level because if the domain model is stable, such expansions can theoretically be resolved at the application layer. So why are there still some people or frameworks attempting to build extension points at the domain level? I think it may be due to the following reasons:
- Building a large-scale complex platform project and consolidating domain capabilities from multiple dimensions; for the application layer, more is about some application adaptation, making the boundaries between the application layer and the adaptation layer relatively blurred.
- Inappropriate management of domain capabilities leading to inappropriate expansion schemes. For example, if a platform project evolves according to DDD principles, there’s no problem initially. However, as business access and scenario support increase, the complexity of the domain layer also increases. During iterations, the domain layer becomes uncontrollable, making the responsibilities for domain capabilities and application layer capability arrangement unclear.
- The underlying models in the domain cannot keep up with changes in the business model, leading to a mapping bias between the domain model and database model. In later iterations, the database model may not be updated for a long time while new business scenarios continue to stack on top of the old database model. Without updating the domain model or simply adapting it, complexity will manifest at the domain layer and spread up to the application layer.
Here’s a simple example to illustrate this point: a case from the product domain. Let’s start with the simplest domain capability.
For instance, SKU and SPUs’ stock. The simplest implementation is that one SPU corresponds to one SKU. However, as business changes require support for multiple SKUs per SPU, while database models support it, the domain layer may not. If the domain layer does not support this, further adjustments are needed in the domain layer to adapt. Now, let’s consider distinguishing between frontend and backend SPUs, where both are many-to-many relationships but SKUs remain one-to-one. The domain layer can easily identify and adjust such distinctions. However, at the database level, significant changes would be required, such as adding a linking table or fields with self-referential types, which clearly violate database design norms. If we do not update the database model to adapt to the domain’s changes, adding another distinction for frontend SKUs will require substantial adjustments in the domain layer but even more at the database level.
3. Types of Extension Points
3.1 Parallel Expansion
Here, based on Java language characteristics, we divide it into two cases and continue with the example from a previous article about the KVPairBO object modeling, expressing it using PlantUML class diagrams as follows:
- Abstract Class Extension
@startuml
abstract class "Abstract Generic KV Business Operation Service Class - AbstractKVPairService" as AbstractKVPairService{
getAll(): List<KVPairBO>
getById(Long id): KVPairBO
insert(KVPairBO kVPairBO): KVPairBO
containsKey(String key): boolean
}
abstract class "Persistent KV Business Operation Service Class - PersistKVPairService" as PersistKVPairService{
getAll(): List<KVPairBO>
getById(Long id): KVPairBO
insert(KVPairBO kVPairBO): KVPairBO
containsKey(String key): boolean
}
PersistKVPairService --|> AbstractKVPairService
class "Grouped KV Business Operation Service Class - GroupKVPairService" as GroupKVPairService{
containsKey(String key, String groupKey): boolean
getListByGroupKey(String groupKey): List<KVPairBO>
getAllMap(String groupKey): Map<String, KVPairBO>
}
GroupKVPairService --|> PersistKVPairService
class "Object KV Business Operation Service Class - ObjectKVPairService" as ObjectKVPairService{
getListByRelationObj(String relationObject): List<KVPairBO>
getListByRelationId(String relationObject, Long relationId): List<KVPairBO>
update(KVPairBO kVPairBO): boolean
deleteById(Long id): boolean
deleteByRelation(String relationObject, Long relationId): boolean
}
ObjectKVPairService --|> PersistKVPairService
class "Tree KV Business Operation Service Class - TreeKVPairService" as TreeKVPairService{
getListBySuperId(Long superId, boolean loadAllChild): List<KVPairBO>
containsKV(Long superId, KVPairBO): boolean
deleteBySuperId(Long superId): boolean
}
TreeKVPairService --|> PersistKVPairService
@enduml
- Interface Extension
@startuml
interface "Generic KV Business Operation Service Class - KVPairService" as KVPairService{
getAll(): List<KVPairBO>
getById(Long id): KVPairBO
insert(KVPairBO kVPairBO): KVPairBO
containsKey(String key): boolean
}
interface "Grouped KV Business Operation Service Class - GroupKVPairService" as GroupKVPairService{
containsKey(String key, String groupKey): boolean
getListByGroupKey(String groupKey): List<KVPairBO>
getAllMap(String groupKey): Map<String, KVPairBO>
}
interface "Object KV Business Operation Service Class - ObjectKVPairService" as ObjectKVPairService{
getListByRelationObj(String relationObject): List<KVPairBO>
getListByRelationId(String relationObject, Long relationId): List<KVPairBO>
update(KVPairBO kVPairBO): boolean
deleteById(Long id): boolean
deleteByRelation(String relationObject, Long relationId): boolean
}
interface "Tree KV Business Operation Service Class - TreeKVPairService" as TreeKVPairService{
getListBySuperId(Long superId, boolean loadAllChild): List<KVPairBO>
containsKV(Long superId, KVPairBO): boolean
deleteBySuperId(Long superId): boolean
}
class "Generic KV Business Operation Service Implementation Class - KVPairServiceImpl" as KVPairServiceImpl{
}
class "Persistent KV Business Operation Service Implementation Class - PersistKVPairServiceImpl" as PersistKVPairServiceImpl{
}
class "Grouped KV Business Operation Service Implementation Class - GroupKVPairServiceImpl" as GroupKVPairServiceImpl{
}
class "Object KV Business Operation Service Implementation Class - ObjectKVPairServiceImpl" as ObjectKVPairServiceImpl{
}
class "Tree KV Business Operation Service Implementation Class - TreeKVPairServiceImpl" as TreeKVPairServiceImpl{
}
KVPairService <|.. KVPairServiceImpl
KVPairService <|.. PersistKVPairServiceImpl
GroupKVPairService --|> KVPairService
GroupKVPairService <|.. GroupKVPairServiceImpl
ObjectKVPairService --|> KVPairService
ObjectKVPairService <|.. ObjectKVPairServiceImpl
TreeKVPairService --|> KVPairService
TreeKVPairService <|.. TreeKVPairServiceImpl
@enduml
Parallel expansion is a typical case like SPI, which can also be considered as plug-in or detachable.
3.2 Inflationary Expansion
Here are some specific types of inflationary expansion, involving some design pattern content. Let’s use another example: matching discount rules in marketing scenarios.
- Code Method Internal Extension (Violates Open/Closed Principle)
Let’s represent this with a service class as follows (pseudo-code):
public class CouponCalculateService{
// Determine if coupons can be used based on coupon list and order details.
public int calculate(List<Coupon> couponList, String orderCode){
Object order = getDetail(orderCode);
// Orders under 100 yuan cannot use any coupons for deduction.
if(order.sumCount < 100){
return 0;
}
// For orders between 100 and 200 yuan, find a coupon with an amount less than 20.
else if(order.sumCount > 100 && order.sumCount < 200){
return couponList.stream().filter(coupon -> coupon.amount < 20).findFirst().get().amount;
}
// For orders over 200 yuan, find a global coupon.
else if(order.sumCount > 200){
return couponList.stream().filter(coupon -> coupon.isGlobal).findFirst().get().amount;
}
// TODO list
// a. Business line A needs to support small discount calculations?
// b. Business line B needs to calculate using coupons from the store and user-claimed discounts.
// c. Business line A needs to exchange points for specific small-value coupons for discount calculation?
}
}
This example illustrates how such internal method extensions can become more complex and uncontrollable over time.
- Interface and Method Extension at Class Level
Here, we define new discount calculation capabilities using interfaces and class methods as follows:
Adding methods and classes still somewhat violate the Open/Closed Principle but are generally better than the first method.
- Decorator Pattern Extension
This is similar to applying multiple coupons simultaneously, such as when an order exceeds 1000 yuan, it may have more discounts. If paying with a credit card or binding to a certain payment channel, there could be additional scenarios for discount calculations. We can wrap the regular discount model to apply discounts based on the amount of the order.
3.3 Inheritance Expansion
Inheritance expansion is a common form of extension, derived from one of Java’s three core object-oriented features. Many times, we can enhance and extend business capabilities using inheritance mechanisms. However, due to the lack of restrictions in inheritance, it is not recommended for use in business code.
Here, let’s use cooking as an example. Using beef to make a dish. We define a beef recipe first: Braised Beef.
Now, we need to upgrade braised beef by adding potatoes. So the new feature becomes: Braised Beef with Potatoes.
Next, we don’t want to eat regular beef anymore; instead, we want to further upgrade it into brisket. For better taste, so the new feature becomes: Braised Beef with Potatoes - Braised Brisket with Potatoes. Now, a customer says they want to change potatoes to white radish and add more coriander for garnish, requesting extra soy sauce for mixing rice. So this dish has transformed from braised beef into a VIP version of the cuisine.
3.4 Composite Expansion
Composite expansion can also be considered mixed expansion, meaning that there are some modifications in the main process logic at places where extensions are needed, leading to a combination of extension layers and ultimately making the code and execution flow complex.
3.5 Enhancement Expansion
Here, enhancement expansion includes several situations such as AOP aspects, execution filters, etc., which are technical implementations. For example, using dynamic control in AOP for parameters and return values, filtering specific strings, etc. Since these expansions are not particularly complex and generally do not deeply apply mechanisms for business extensions, the complexity is still somewhat manageable.
4. How to Solve Extension Point Business Issues
4.1 Brief Summary of Extension Point Problems
From the theoretical analysis above, extension point businesses indeed become very complex. If we’re not careful, core systems will be filled with a lot of if-else logic. Those who have worked at Alibaba would roughly understand products like TMF and Starbene, as well as other business frameworks. The essence is to solve how to build a mid-platform that supports the various business lines’ extension points within it. On the surface, the mid-platform provides various business capabilities and a capability map, making those capabilities explicit. Other support comes from lower-level frameworks. Generally, large companies do not open up their solutions too deeply. As smaller companies’ technical personnel, how can we solve this problem? There are several dimensions that can be discussed:
4.2 Framework Dimension
Here, I provide two directions for solving extension points in the framework dimension.
- Control Extension Capabilities
Because of the implementation and intrusion of extensions into the main business process flow, managing extensions becomes difficult. Open-ended or uncontrolled extensions are essentially no extensions at all; once applied, they still cannot solve the complexity issues caused by extensions.
- Expressing Extension Scenarios
This direction is because extension points definitely differ from core processes or standard implementations. For business users, it’s about expressing personalized extensions first. Therefore, maintainers might focus on standard implementations instead of these scenarios, leading to a difference in perspectives between them. Thus, the framework should be able to express extension point scenarios well so that both parties can focus their attention on these scenarios. Not only should code reflect extension calls and descriptions, but also visual interfaces and call chains need to convey this information. Therefore, more work needs to be done at the framework level, benefiting maintainers as well as callers.
4.3 Code Design Pattern Dimension
- Strategy Pattern Expansion
Strategy pattern expansion is a clear example of parallel expansion. In most cases, such extension strategies are very useful but can become complex when there are too many strategy or rule scenarios, leading to an increase in the complexity of strategy classes. Without proper refactoring and restructuring, complexity will inevitably rise.
- State Pattern Expansion
Often, we use state patterns for simple state flow control, or based on state machines to drive them. Encapsulated state machine components can appropriately control complexity, but state transitions are still complex. A more classic example is workflow engines; many enterprises base their engines on various business scenarios. Therefore, for such complex starting points, it’s recommended to make them relatively flexible from the beginning by separating technical complexity and controlling extension capabilities to possibly control system complexity.
Of course, there are other patterns of expansion here as well, but we won’t delve into them further.
4.4 Capability Arrangement Dimension
Thinking about this dimension presupposes that application and service capabilities (leaving the domain aside for now) are already sufficient, and that we need to support further scenarios from what already exists, so that capabilities can be replicated. An extreme case: the application module has grown so large that I no longer want to extend it — I hand you the core model and you extend it yourself. Of course, that veers off topic. In the normal case, we extend inside the application project: once interface methods and business flows are numerous enough, we can make those capabilities concrete, for instance putting the whole payment domain capability on a visual interface.
When mid-platform developers are in short supply, or when an API similar to an open-platform API is needed, we can use tooling such as PlantUML sequence diagrams or activity control flow diagrams to express the logic of the extension scenario. At the code level, that scenario is just one call, or just a facade layer — an adapter, in other words. My own application stays extendable as it is, and I do not need to write extension code for it.
4.5 Domain Design Dimension
From a domain design perspective, extension points are like viruses (rebellious sons) that always try to impact the domain model and capabilities from different angles. Otherwise, they can seep into application layers and infrastructure layers, increasing the complexity of the entire application system engineering. Here, I think there are some aspects we can try:
- Strictly distinguish core domain capabilities, standard domain capabilities, and extension domain capabilities in the domain layer.
- Identify whether business contexts behind extension points have been adequately expressed; ensure that domain models + database models support extensions without affecting existing system domain logic.
- Flexibly apply various abilities exposed by the domain layer (such as redundant code, proper arrangement, generic abstractions, etc., strategies) at the application layer.
- From a team collaboration perspective, analyze whether extension points need to be supported by system maintainers or if they can be co-built with extension logic, adding an additional layer of shared maintenance in the application and adaptation layers. Of course, this requires more support for building.
4.6 Implementation Dimension
Looking at how to solve extension point issues from a software requirements analysis and technical design perspective. From a requirements standpoint, relevant personnel must identify which are needed extensions and which may be extended in the future, similar to plugin mechanisms. Therefore, when software designers or system maintainers implement these requirements, they will consider which extension points need to be addressed and reserve appropriate elements for extensions in domain models and database models. For example, defining field enums, based on interfaces and abstract classes to define core capabilities, designing SPI support mechanisms from the start, etc. Of course, as more extension points are added, strategies must be considered to control the complexity of software due to these extension points. Such as scripting, dynamicization, configuration, etc.
4.7 Essence of Various Dimensions
The analysis and control of extension points from various dimensions essentially aim to control branch processes outside the core process or main business flow, keeping the complexity of these branch processes at a certain level to ensure smooth service calls between services.
5. Conclusion
This article discusses why extension points become the enemy of mid-platforms and DDD by exploring their business implications, analyzes the types of extension points that may lead to increased software complexity, and provides solutions from different dimensions to control this complexity. Overall, extension points are not scary; various branch businesses and expansion nodes are also not scary. What is scary is our lack of better methods and strategies to observe them, evaluate them, and solve them.
Overall, to address the complexity issues caused by extension points, it’s necessary to explicitly express these extension point business scenarios and manage them through certain mechanisms from different dimensions while monitoring their behavior in the business process.
6. References
6.1 Baidu Encyclopedia Definition
https://baike.baidu.com/item/%E6%89%A9%E5%B1%95%E7%82%B9/56097152?fr=aladdin
6.2 COLA2.0 Extension Point Implementation
https://blog.csdn.net/significantfrank/article/details/100074716?spm=1001.2014.3001.5501
6.3 TMF2.0
https://developer.aliyun.com/article/291244
6.4 Extension Point Design Case Study
https://www.jianshu.com/p/a20e1793f6d9
Comments
Comments are powered by GitHub Discussions. Sign in with GitHub to join the discussion.