Writing Maintainable Code: Low Coupling
December 13, 2025
In this unit, we'll discuss coupling and how understanding this principle helps us write code that's easier to modify and extend.
Most developers have heard the phrase "high cohesion, low coupling" mentioned together. We covered high cohesion in the previous unit. In this unit, we'll dive deeper into low coupling, showing how these two concepts work together to make our code more maintainable.
Complexity and Maintainability
Let's review what we learned earlier. To make code maintainable, we need to keep its complexity low. There are two key metrics to consider:
- The first is readability: if someone unfamiliar with the code encounters it for the first time, can they understand it in a short amount of time?
- The second is modifiability: if someone needs to change this code in the future, will they struggle to make modifications, or can they do so relatively easily?
From a coupling perspective, while it doesn't directly help with readability, reducing coupling significantly improves modifiability. From a complexity standpoint, low coupling is extremely helpful.
What is Coupling?
First, let's understand what coupling means. Coupling refers to the degree to which things are interdependent—whether two components depend on each other and are tangled together. If they are, coupling is high. If they operate independently with minimal interdependence, coupling is low.
We actually see different levels of coupling in everyday life, not just in code.
Consider a common example: when Apple released its iPhones, they used proprietary Lightning connectors. The problem with Lightning connectors is that if an iPhone user forgets their charging cable while out, they can't borrow from Android users who have standard USB Type-C cables.
In this situation, because the iPhone is tightly coupled to the Lightning connector, the user can't charge their phone with a Type-C cable. This creates a real problem: if you forget your cable and everyone around you uses Type-C, you're stuck.
In contrast, if you use an Android phone with a standard Type-C connector and forget your cable, it's no problem. Because your phone's charging port isn't coupled to a specific manufacturer's cable, you can easily use anyone's Type-C cable, regardless of the brand.
Decoupling with the MCP Protocol
Now that we understand coupling through the charging connector example, let's look at how coupling affects technical and software design.
Let me introduce an important concept that comes up frequently in AI discussions: MCP. When MCP was introduced, it was essentially about solving a coupling problem.
Before the MCP protocol existed, when AI models needed to connect to external tools—for example, allowing GPT to connect to GitHub tools so it could help us create PRs or modify code based on PR comments—the approach was to use function calling.
The problem is that each AI model provider has its own proprietary function calling implementation. In other words, the function calling interface is coupled to a specific AI model. This means GPT has its own function calling method, and Gemini has a different one. If you build a function calling for GPT, you can't reuse it with Gemini because it's coupled to GPT.
From a maintainability perspective, this is inefficient. Every time a new model comes out, you need to write function calling specifically for that model. This increases development costs significantly.
MCP was introduced to solve this problem. MCP is a protocol that acts like a standard interface. Just like how any phone supporting USB Type-C can use the same charging cables, any AI model supporting the MCP protocol can connect to MCP-compatible tools.
If you build a GitHub MCP tool, it can work with different models or tools like Cursor or Copilot. This means you only need to develop one GitHub MCP, and it works everywhere. Compare this to the previous approach, where you'd need to repeatedly write similar function calling code for each different model with only slight variations.
By removing the coupling between tools and models, we increase maintainability.