Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

O: Open-Closed Principle - Eloquent Attribute with Salary Calculator

Premium
4:04

The Full Lesson is Only for Premium Members

Want to access all of our courses? (29 h 14 min)

You also get:

54 courses
Premium tutorials
Access to repositories
Private Discord
Get Premium for $129/year or $29/month

Already a member? Login here

Comments & Discussion

C
ccarlosm ✓ Link copied!

Hi!, I t looks to me that creating and using the array $calculators to define the different calculators is breaking the Open-Closed principle itself since we would have to modify it if we add future calculators. With the dinamically class creation this does not happen, but I am wondering if there is not another way to do it, though this one seems more correct indeed. Thanks!

PK
Povilas Korop ✓ Link copied!

Interesting point. To be honest, after shooting this course and trying to implement it in practice, I realize more and more that these principles are more THEORETICAL and sometimes breaking them is ok. So if using the array $calculators is actually making problems to your code maintainability in the future, then sure, refactor it in another way you prefer.

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.