Khuyen Tran Profile picture
MLOps Engineer | Share 700+ tips on Python and data science
Oct 3 4 tweets 1 min read
Use the Open-Closed Principle to create easily extendable classes without modifying existing code. This approach reduces the risk of introducing bugs in existing, tested code and allows for easy addition of new features or functionalities.

In the example below: Image 1. First Approach: DataVisualizer uses conditional logic to choose charts. This requires changes to the visualize method whenever a new chart type is added.