Design principles

Continuing at the cliffhanger of the last post, we need good design. How do we do that?

First, budgets. Budgets have two main constraints upon any project, time and money.

In order to minimize Risk (you remember RISK don’t you?), the useless needs to be avoided.

Why waste time and or money solving a problem someone else already did? There are a set of common solutions called design principles.

They help us write quality code.

The first one is Open-Closed Principle. The focus here is that an object or class allows different functionality to be added to it but not directly, instead it is added through extension in a subclass. That modified behavior would only be added to the subclass and not to the parent’s core functionality.

The second principle is Don’t Repeat Yourself principle.

This goes with the first concepts you learn in OOP. Avoiding code duplication and abstracting it to an external class possible to have cleaner code and save resources.

The third principle is Single Responsibility principle.

Also very much related to the OOP basics, have every object focus on one thing only instead of multiple. That way for any behavior modifications, it will be easier as well.

Last principle is Liskov Substitution Principle.

This doesn’t have a self-describing name but basically it is about using inheritance correctly. The main object’s functionality or methods should mostly work in the subclasses as well, otherwise it’s breaking the principle. If that is not possible, then such functionality should be delegated to another object.

Photo by Dorli Photography via Flickr
This is a wall of tools, tools help us be better and fast at certain tasks. They have some learning curve however.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s