Changes are really difficult to make if components have lots of dependencies on each other, or if they’re doing multiple things at once — often these issues come together.
If we can disentangle the spaghetti code we can make our lives a lot simpler.
Here’s how we can do this:
- Single Responsibility Principle (SRP) — Each component should have a specific and clear purpose. This makes it easier to know where new code should go, or how to use a component. If you can’t come up with a good, meaningful name easily, then that’s a sign the component is probably doing too much.
- Isolating knowledge — Keep knowledge about domains, systems, and decisions encapsulated in a single spot. This is DRY code in action, and makes it easier to update things in the future since we don’t have to track down multiple places all over our code base.