From the course: Learning SOLID Programming Principles

What could go wrong?

- [Instructor] I'd like to introduce the SOLID Design Principles. There are five principles I want to share with you, first though, I need to share why these ideas are so important. Software is always in a state of flux. It's essential to ask, what could go wrong when someone needs to make a change to our software? The state of flux is like tossing pebbles into water, each pebble has ripples, ideally, each change is isolated. It's best if there's a way to confine the ripples to prevent adverse consequences. In an O, O programming language like Python, class definitions can be used to confine the ripples of change. A class allows programmers to isolate the various concerns that comprise working software. For example, we can disentangle algorithms and data structures from the operating system details. The SOLID Design Principles provide guidance on how to structure our classes in a way that keeps the concerns separate and minimizes the ripples of change. Here's my real-world problem. It's like enterprise business analytics and it involves a sprinkling of data science. I live on a boat and this diesel engine is very important. On the other side of the engine, there's a new alternator. It generates electricity to charge the batteries and it provides a signal for the tachometer at the helm that shows the engine revolutions per minute, the RPMs. Here's another picture of the alternator, what's important is the serpentine belt on the new alternator has smaller wheels than the old alternator had. It turns faster and generates more current, which is nice, however, I can't easily recalibrate the tachometer and I certainly don't want to buy a new one, so instead, I want to create a model to translate from the RPMs shown on the old tachometer to the actual engine revolutions per minute. In order to do that, I gathered some data, I ran a few experiments using a photo laser tachometer which has to be used manually down inside the engine room, do these tach and engine values even correlate? And if they do, is there a simple regression function that will map readings on the tachometer to the actual engine RPMs? What I did was design this correlation class. It has a method read, to read the sample data from a file and it has this method R to compute the coefficient of correlation, and this method got to be kind of complex and worse, this isn't exactly what I need, I have to make some changes to this class, what can go wrong?

Contents