Writing clean code is tough, and is one of the largest differences between junior and senior developers. One way that you can quickly improve your code and start writing well designed code now is to implement the open/closed principle. This principle is part of the SOLID design principles and is, in my opinion, the most complex rule of SOLID. This is because the definition is difficult to understand, but once you wrap your head around the idea it is very easy to implement.
The main idea of the open/closed principle is that every class/function/module/section of your code should be open for extension and closed for modification. This means that a class/function/module should be able to be extended in functionality without having to go into the class and change it. Essentially you shouldn’t need to change existing code to add new functionality and instead should only have to add new code.
Most likely you have written tons of code in violation of this principle, I know I have, but hopefully this video will help introduce you to why this principle is so good at making your code clean and maintainable.
🧠 Concepts Covered:
– What the open/closed principle is
– Why the open/closed principle is important
– How to use the open/closed principle
– How to spot violations of the open/closed principle
🌎 Find Me Here:
My Blog: https://blog.webdevsimplified.com
My Courses: https://courses.webdevsimplified.com
Patreon: https://www.patreon.com/WebDevSimplified
Twitter: https://twitter.com/DevSimplified
Discord: https://discord.gg/7StTjnR
GitHub: https://github.com/WebDevSimplified
CodePen: https://codepen.io/WebDevSimplified
#SOLID #WDS #OpenClosedPriniciple
source