|
"High cohesion, low coupling" is one of the most misunderstood principles in software engineering. So, let's clear things up! TL;DRCohesion is about the internal focus of a thing - how well its components work together to fulfil a single purpose. Coupling is about the external relationships between things - how much they depend on one another. CohesionWhen applied to a code module, cohesion measures how closely related its functions are. An Authenticator module will likely have high cohesion because all its functions are related to handling authentication. On the other hand, a Utils module is likely a dumping ground for unrelated helper functions and will, therefore, have low cohesion. When applied to a system, cohesion measures how well its components (services, subsystems, etc.) work together to achieve a single goal. A service with well-defined boundaries and responsibilities will have high cohesion. Conversely, a system has low cohesion if its components are poorly aligned and have overlapping or unrelated responsibilities. For example, a User service that handles authentication, account management and sending notifications about account updates. CouplingA good way to think about coupling is in terms of change propagation. That is, how much does System B need to change if we change System A. Coupling is everywhere and comes in many different forms. Some coupling (e.g. data format dependency) requires coordinated changes between systems. Other forms of couplings are less obvious but more problematic to deal with. For example, temporal coupling links the availability of one service to another. This often leads to cascade failures and necessitates other practices (e.g. retries, exponential backoff, fallbacks, chaos engineering and so on) to mitigate. ----- So there you have it, the difference between "Cohesion" and "Coupling". They measure similar but, ultimately, different qualities in software. |
Join 17K readers and level up you AWS game with just 5 mins a week.
Modern applications rarely do just one thing at a time. An API request creates an order, and then another service needs to reserve stock, another to charge the customer, another to send an email, and so on. In a serverless or event-driven architecture, follow-up actions are usually triggered by messages (either events or commands). That gives us loose coupling, better scalability, and independent services. But it also introduces a reliability problem. “What happens when the database update...
If you use Claude Code a lot, you’ve probably run into usage limits, sometimes even in short coding sessions. But cost isn’t the only problem. In long-running sessions, the context window eventually fills up, and that can cause the agent to forget earlier decisions, lose important details, or come back from compaction with gaps in its working memory. Here are three tools worth checking out if you want to reduce token usage and make longer coding sessions possible. 1. CavemanThis is a Claude...
AI agents can now scan an entire open-source codebase for exploitable vulnerabilities in hours. Frontier models carry the complete library of known bug classes in their weights. So you can simply point an AI agent at a codebase and tell it to find zero-days. This isn't theoretical. Willy Tarreau, the HAProxy lead developer, reports that security bug reports have jumped from 2–3 per week to 5–10 per day. Greg Kroah-Hartman, the Linux kernel maintainer, described what happened: "Months ago, we...