Originality is Overrated

When we think about quality, we often think we should create everything from scratch, from zero and all the subsystems in the code should reinvent the wheel. Nothing can be further from reality.

The truth is this: There are number of already built solutions for helping us develop faster and smarter, one of which is design principles, and is not wrong to use them, they exist with the purpose of making the code more understandable, mantainable, flexible, and upgradable.

These are the principles of design:

  • Open-closed is a principle made for classes that stipulates openness in a class for expansion and closeness for modification. No other person should be able to modify the class you are working on, but they can inherit from it in order to expand the class.
  • Don’t repeat yourself identifies the common behaviour and puts it in one place. this facilitates the changing and mantainability of the code.
  • Single Responsability mentions the purpose of classes and how there should only be one purpose per class, and they have only one reason to change.
  • Liskov Substitution is about inheritance. Objects can inherit from other classes, right? Now if the child class (or the class that inherits from someone else) cannot be treated like the parent class, there is something wrong.
  • Delegation is when you ask for help to another class with a particular behaviour but it is not the main function  of the helping object.
  • Composition is the dependecy of objects that are put as attributes in a bigger object.
  • aggregation similar to composition, except with composition the attributes need the bigger object to exists, in the other hand aggregation is independent objects helping other objects

Leave a comment