Skip to main content

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? (36 h 00 min)

You also get:

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

Already a member? Login here

ccarlosm avatar

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!

👍 1
Povilas Korop avatar

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.

👍 1

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.