~/software-design/software-design-principles.md

Principles of Software Designing

1 min readJuly 02, 2019by Gorav Singal#software-design#design-patterns
// TL;DR

Favor composition over inheritance, program to interfaces not implementations, and keep classes loosely coupled. These principles underpin every major design pattern.

Principles of Software Designing

It is very easy to build a software or app. But, it is trickier to have a good design that gives you good maintainability over long period of time, and that serves the purpose.

Listing down few design principles that can help greatly in designing applications or softwares:

Move the code what varies and encapsulate it so that it wont affect rest of the code

In simpler terms: Identify the aspects of your application that vary and separate them from what stays the same. It will result in more flexibility in your code. And, this is very powerful concept, as it is being used in many design patterns.

Program to an interface, not an implementation

It gives you a lot of flexibility in changing the actual implementation at any time, without the need to change the code. Or, change in smaller portion of the code. Otherwise, you are bound to some implementation, and for every new implementation change, you need a massive code change.

Favor composition over inheritance

Inheritance is good but in practical, this can become overhead. Many beginner consider it as re-usability. But, Composition provides reusablity. It provides several benefits like: - You can encapsulate the implementation or algorithms - You can change the behavior at runtime - You can have list of that object instead of inheritance

$ subscribe --weekly

One deep dive a week, in your inbox

System design, AI engineering, trading systems and interview prep. Tested code, real numbers. Free, and you can unsubscribe any time.

or read it on gyanbyte.substack.com

Share

Related Posts

Singleton Pattern with Thread-safe and Reflection-safe

Singleton Pattern with Thread-safe and Reflection-safe

What is a Singleton Pattern Following constraints are applied: Where we can…

The Transactional Outbox Pattern: Never Lose an Event Again

The Transactional Outbox Pattern: Never Lose an Event Again

This is one of those patterns that looks like nothing until you get burnt once…

Event Sourcing, Explained: Store What Happened, Not Just the Final State

Event Sourcing, Explained: Store What Happened, Not Just the Final State

Here is a question I like to ask in interviews: your bank account shows a…

Change Data Capture (CDC): Stream Every Database Change Without Touching Your App

Change Data Capture (CDC): Stream Every Database Change Without Touching Your App

Your orders live in Postgres. But you also need them in Elasticsearch for search…

CQRS Pattern, Explained Simply: Split Your Writes From Your Reads

CQRS Pattern, Explained Simply: Split Your Writes From Your Reads

Most of us start our career with one model for everything. The same class, the…

The Circuit Breaker Pattern: Fail Fast, So One Dead Service Doesn't Kill Them All

The Circuit Breaker Pattern: Fail Fast, So One Dead Service Doesn't Kill Them All

Like the electrical switch in your home that it is named after, a circuit…

Latest Posts

How to Stay Valuable as a Software Engineer in the AI Era: A Practical Playbook

How to Stay Valuable as a Software Engineer in the AI Era: A Practical Playbook

In the previous article I argued that AI is not killing software engineering…

How to Review AI-Generated Code: A Checklist for Catching What the Model Missed

How to Review AI-Generated Code: A Checklist for Catching What the Model Missed

A few months back I approved a PR that was almost entirely AI-generated. It…

How to Debug AI-Generated Code: Understand First, Fix Last

How to Debug AI-Generated Code: Understand First, Fix Last

In the last article I wrote about reviewing AI code before it goes in. This one…

The Future of Software Engineering: What AI Changes, What Stays, and Where the Jobs Go

The Future of Software Engineering: What AI Changes, What Stays, and Where the Jobs Go

Every few weeks somebody sends me a scary headline — “AI will replace all…

The Transactional Outbox Pattern: Never Lose an Event Again

The Transactional Outbox Pattern: Never Lose an Event Again

This is one of those patterns that looks like nothing until you get burnt once…

Event Sourcing, Explained: Store What Happened, Not Just the Final State

Event Sourcing, Explained: Store What Happened, Not Just the Final State

Here is a question I like to ask in interviews: your bank account shows a…