Ahmed Shalaby

Month: September 2018

SOLID Principle By Example (L)

September 16, 2018September 23, 2020 Ahmed Shalaby Leave a comment Clean Code

Liskov Substitution SubClass should be replaceable with base class without any behavior breaks. To fix above code, we can do something like this Coding to interface will be how to follow liskuv principle, always make sure that all functions in classes implements same interface will return same type; else you will find yourself violating liskuve […]

Continue reading


SOLID Principle By Example (O)

September 7, 2018September 23, 2020 Ahmed Shalaby Leave a comment Clean Code

Open-Closed Principle (OCP) Open for extension closed for modification. To fix above code, we can do something like this Now when we have change-request in requirements to add paypal method, all we have to do is adding another paypal class implements same PaymentInterface and thats it, so we extended(open for extension) our application with paypal […]

Continue reading


SOLID Principle By Example (S)

September 1, 2018September 23, 2020 Ahmed Shalaby Leave a comment Clean Code

Single Responsibility Principle (SRP) A class or function should have one and only one reason to change To fix above code, we can do something like this Now you have 2 classes each one has one responsibility, with Laravel you can apply “Single Action Controller” method to make sure each class has only one responsibility.

Continue reading


Search for:

Archives

  • February 2021
  • January 2021
  • September 2018
  • January 2014
  • November 2013

Meta

  • Log in
Copyright © 2020 amshalaby.com