|
"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.
Lambda Durable Functions comes with a handy testing SDK. It makes it easy to test durable executions both locally as well as remotely in the cloud. I find the local test runner particular useful for dealing with wait states because I can simply configure the runner to skip time! However, this does not work for callback operations such as waitForCallback. Unfortunately, the official docs didn't include any examples on how to handle this. So here's my workaround. The handler code Imagine you're...
Lambda Durable Functions is a powerful new feature, but its checkpoint + replay model has a few gotchas. Here are five to watch out for. Non-deterministic code The biggest gotcha is when the code is not deterministic. That is, it might do something different during replay. Remember, when a durable execution is replayed, the handler code is executed from the start. So the code must behave exactly the same given the same input. If you use random numbers, or timestamps to make branching...
Hi, I have just finished adding some content around Lambda Managed Instances (LMI) to my upcoming workshop. I put together a cheatsheet of the important ways that LMI is different from Lambda default and thought maybe you'd find it useful too. You can also download the PDF version below. Lambda default vs. Lambda managed instances.pdf