Design Patterns: S.O.L.I.D. Dependency Inversion Principle

Avoiding Dependencies Between Layers As part of the S.O.L.I.D. design principles, the Dependency Inversion Principle (DIP) provides guidance for ensuring layers within the application avoid unnecessary dependencies from coupling. DIP ensures each layer’s modules remain independent of one another and should depend on abstractions instead of concrete details, increasing usability and flexibility to change. In…

Design Patterns: S.O.L.I.D. Interface Segregation Principle

Providing Focused Behaviors for Classes As part of the S.O.L.I.D. design principles, the Interface Segregation Principle (ISP) supports other S.O.L.I.D. principles in providing classes with focused behavior by ensuring interfaces inherited by classes remain lean and focused on specific behaviors. To illustrate ISP, I’ll use examples from the Single Responsibility Principle (SRP) article. I’ll begin…

OOP: Abstract Classes vs Interfaces

Knowing How to Leverage Abstractions Topic Abstract classes Interfaces Implementation details: Some members (methods). No. Fields: Yes No. Inherit from: Abstract class, interface Interface only. Members can have access modifiers: Yes. Abstract members private by default. No. Interface members public by default. Implementation Details: Abstract Classes As illustrated in the next example, the abstract Employee…

OOP: Polymorphism

Leveraging the power of Object-Oriented Programming with Polymorphism Related to inheritance, polymorphism illustrates a powerful advantage OOP over procedural programming. It allows classes created to standardize attributes and behaviors, or provide a consistent interface for objects to later use when instantiated. The example below demonstrates a common scenario where there are different types of employees…