Exploring System Design: Cohesion

Venkatachalapathi Narayanan
3 min readJun 30, 2024

--

Hello, fellow readers! Thanks for stopping by. Let’s delve into something insightful.

Imagine stepping into a room where books lie scattered across the floor, some resting precariously on chairs, and others nestled among other items. It’s a scene of organized chaos, where each misplaced book adds to the challenge of finding that one particular title you’re looking for. As I struggled to find a specific book, it hit me: this mess perfectly illustrates the concept of cohesion in system design.

study room unorganized.

Now, let’s imagine stepping into another room where books are meticulously arranged on sturdy shelves. Fiction, non-fiction, thrillers, and classics each have their designated spots, with titles neatly aligned alphabetically or by genre. Finding your desired book is effortless — simply glance at the labeled sections, reach out, and there it is, waiting for you.

room organized with books

Epiphany:

This analogy vividly illustrates why cohesion matters in designing efficient systems. By structuring components cohesively, like organizing books on shelves, we enhance usability, streamline operations, and simplify maintenance. It’s the difference between a frustrating search in chaos and a smooth, intuitive experience in a well-organized system.

Making Sense of Cohesion

Cohesion: It’s about keeping things together. High cohesion means each module or components focuses sharply on a single task or related tasks, like a well-organized shelf. Low cohesion? Think juggling too many roles at once — chaotic and hard to manage. Let’s dive deeper into the bookshelf analogy to understand cohesion better.

Bookshelf Analogy

Connecting to System Design

After imagining organized room, I started thinking about how this relates to system design by how and why high cohesion matters. Here’s how:

  • Maintainability: Easier to update and fix issues in a system with high cohesion.
  • Scalability: Easier to extend the system with new features or components.
  • Readability: Code is more understandable, making it easier for new developers to get up to speed.
  • Efficiency: Systems with high cohesion are generally more efficient, both in terms of performance and developer productivity.

Below the java code illustration:

Simplified version to find books in Messy Room

public class Main {
public static void main(String[] args) {
MessyRoom room = new MessyRoom();
room.addItem(new Item("book", "Moby Dick"));
room.addItem(new Item("toy", "Lego"));
room.addItem(new Item("book", "1984"));

Item book = room.findBook("1984");
System.out.println(book.title); // Output: 1984

List<String> books = room.listBooks();
System.out.println(books); // Output: [Moby Dick, 1984]
}
}

simplified version to find book in Organized Room

public class Main {
public static void main(String[] args) {
OrganizedRoom room = new OrganizedRoom();
room.addBook("Fiction", new Book("Moby Dick", "Herman Melville"));
room.addBook("Science Fiction", new Book("1984", "George Orwell"));

Book book = room.findBook("Science Fiction", "1984");
System.out.println(book.title);

List<String> books = room.listBooksByCategory("Fiction");
System.out.println(books);
}
}

detailed version of code available here.

Conclusion

By embracing principles of organization and structure — whether in organizing books or designing software systems — we can streamline processes, reduce complexity, and ultimately enhance user experience. These insights encourage us to rethink how we approach design and organization, fostering environments where efficiency and usability thrive naturally.

Reflecting on the Insight

Next time you arrange your bookshelves or encounter a complex system, consider how organizing and categorizing elements could optimize functionality and user interaction. Share your thoughts on practical ways to apply these principles in your daily experiences or professional endeavors!

Until next time, happy reading!

[Previous] | .. | [Next]

--

--