Inheritance Interface Composition: Untangling the Insidious Knot, Now!

interface

Terminology In layman’s terms: Interface is for “can do/can be treated as” type of relationships. Abstract ( as well as concrete ) classes are for “is a” kind of relationship. Look at these examples: Bird, Mosquito and Horse are Animals. They are related. They inherit common methods from Animal like eat(), metabolize() and reproduce(). Maybe … Read more

Unlock OOP: Polymorphism Techniques You Need to Master!

Polymorphism

Polymorphism describes the concept that objects of different types can be accessed through the same interface. Each type can provide its own, independent implementation of this interface. So; is polymorphism just “being able to perform functions of an interface, such as adding, subtracting, etc, on objects of different data types such as integers, floats, etc”? … Read more

Do you REALLY know what SOLID means? (#4: Exclusive Truth about Interface Segregation Principle)

interface segragation principle

Interface Segregation The philosophy of Interface Segregation principle is – larger interfaces should be split into smaller ones. By doing so, we can ensure that implementing classes only need to be concerned about the methods that are of interest to them. The principle states that many client-specific interfaces are better than one general-purpose interface. Clients … Read more

Do you REALLY know what SOLID principles means? (#2: Exclusive Truth about Open Closed Principle)

open closed principle

Open for Extension, Closed for Modification The Open Closed Principle is a popular software design principle that states that classes should be open for extension, but closed for modification. This means that we should be able to add new functionality to a class without modifying the existing code for that class. The reason for this … Read more

Do you REALLY know what SOLID means? (#1: Exclusive Truth about Single Responsibility Principle)

Single Responsibility Principle

Do one thing and do it well!Single Responsibility Principle – This principle states that a class should only have one responsibility. Furthermore, it should only have one reason to change. SRP, like most principles out there, can be over-applied. If we create a new class for incrementing integers, then yeah, that may be a single … Read more