Loosely Couple Code

Rafael A. George Duval
2 min readSep 16, 2022

--

Object ignorance means an Object-Oriented Programming programming style where you strive to make objects know as little about one another as possible.

In more formal terms, this means reducing the number of dependencies in each object.

Objects with fewer dependencies know less about their surroundings and need a smaller context. An object that’s context independent can be reused in novel ways.

You can tell how much context an object requires by looking at the setup needed to test it — piles of setup or show lots of necessary contexts. Little or no test setup indicates that the object is independent of context.

An object that’s context independent is not coupled to the other parts of the application. These objects are amenable to being used in unexpected situations.

Loosely couple objects have limited knowledge about the environment or dependencies. The objects define the role those different implementations can play.It is possible to substitute across the boundary of whoever plays the role.

The benefit of Loosely couple objects is that changes to the arrangement of groups of things don’t break everything in the application.

The disadvantage of loose coupling is that you can’t look at the source for any individual object and understand the context in which it’s used.

Applications change in unexpected ways. Optimizing for a small group of objects that put a functionality or loosely coupled code in place is the most effective way to manage uncertainty.

External dependencies might become obsolete.The reduced coupling between the application and its dependencies enables the team to switch technologies or business partners.

Strive for loose coupling everywhere so that you can make changes anywhere.

--

--

Rafael A. George Duval
Rafael A. George Duval

Written by Rafael A. George Duval

✍🏼 Building a Solo Digital Media Company 🧪 Snippets of Text [https://snippetsoftext.substack.com/subscribe]

No responses yet