Validate model with Strategy Pattern to keep Open–Closed Principle

Defensive Programming with Strategy Pattern Defensive programming is an approach to programming that attempts to ensure that software still functions under adverse or unforeseen circumstances. Open–Closed Principle Classes, functions, and modules should be closed for modification but open for extension. That means closed for modification and open for extension. Adding new functionality should not modify existing source code. A component should be extendable to make it behave in new ways. Why Strategy pattern? The Strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable.