From the course: Learning SOLID Programming Principles

What could go wrong? Part 2

- [Instructor] I created a class to solve my data analytics problem, but I designed this class without following any of the solid design principles. And while the class works, it doesn't really do what I want. Here are some of the problems. Here's the first one. The CSV column names in the file are wrong. My file doesn't have columns named x and y, they're called Tech and Engine. If I try to make this change, there are a lot of places where I need to make that column name change. Here's another problem, perhaps not as big. There are a lot of steps in the main function. This correlation class demands a lot of individual steps to compute the correlation between the two columns. Specifically, it seems really unnecessary to expose the x values and y values methods, especially because in the long run, the column names are wrong. And here's another big problem. There are a lot of computation steps for computing the linear regression parameters shown in this new method that I'd like to add. It turns out that the code for computing the correlation coefficient is almost identical to this code, but it's hard to figure out how to reuse the original overly complex method, so there's a certain amount of copy and paste in here that is difficult to maintain. There are several problems in my original code. It helps to articulate the problems and some of the consequences of those problems. This is an important first step in applying the solid design principles. But if all I do is identify the problems, I'm not really helping, because I'm not solving them. It's important to take the second step and propose a solution based on the solid design principles that will fix the problems and prevent additional problems when we have to make further changes. One key point about the solid principles. They're not a style guide or a superficial approach to developing code. These principles may require significant rework to poorly designed code. I want to start with an overview of the solid principles and after the overview, each of the next five chapters will look at how the principles apply in my case study data analysis and modeling problem.

Contents