 All right, so this section we're going to talk about being solid now. What is solid well It's an acronym for five design principles intended to make software design understandable and easy Flexible and well it should just work. I mean at the end of the day. That's what we're getting done is code We want things to work So what solid really does is it breaks it down into five respective parts as for single responsibility O for open close L for list gov substitution principle I for interface segregation principle and D for dependency inversion principle These are a little bit tricky. So what we're going to cover in this specific video is this single responsibility principle or SRP basic terms Do something simple Do it well have a single responsibility and do what you say you're going to do I can't tell you the number of times somebody sends me a class that says dog But the dog is flying around and mowing the lawn and doing all these things that dogs just don't do So let's take a look at a good example here. So we're going to go new Let's go ahead and make a console app. And this is two dash one and I'm just off the screen here Gonna grab some notes Rather than typing all of that out So we're talking about the single responsibility principle So what we're going to do is design a class that has a single responsibility here. So we're going to add new class and let's call this temp converter So our temp converter. Well, there's really there's different types of temperatures out there But really what we're going to be focused on is well how to convert between Celsius and Fahrenheit so Let's go here And I'm just going to paste in the function names rather than try and type all that gobbly cook out We'll be here all day So Celsius to Fahrenheit Fahrenheit to Celsius and these two While simple on the surface are easy to screw up and it's very tempting To add a lot more that we don't need for example void to int or You know, why would we say void to it? But you know what? I mean, it's very tempting to add a lot of what are called utility functions in here And we really really shouldn't There are better ways of doing that. So keep it simple Do what you say you're going to do. So let's actually finish this thing out here So we're going to right-click refractor add definition switch back If it seems like I'm whipping through this it's because again, we are not in beginners land. So We're going to convert from Celsius to Fahrenheit Judicious use of the auto keyword and we're going to say oh for output and we want the value times 9.0 I Probably really screwing this up because I am not a weatherman and We're going to say plus 32 So that should convert Celsius to Fahrenheit and then we need to go ahead and return Our output could have all just done that on one line, but I felt like doing it this way. So auto output equal Some people don't like auto. I think it's actually a dream come true for C++, but it is what it is So from going from Fahrenheit to Celsius. We want to go value minus 32 And then we want to you multiply that by 5.0 Divide that by 9.0 Again, I am not a mathematician. I'm not an expert in weather patterns I probably have screwed up the math on that but it should give us a fairly close representation now I'm going to just say it. We're not really focused on this little algorithm here. We're focused on the overall pattern which This is why I love header files because it takes all of that implementation and hides it and we can say okay So does this class match? Solid meaning is it simple? Is it easy to use? Does it have a single? Responsibility yes, it does it converts from one temperature to another and it does exactly what it says it's going to do It converts a temperature. It doesn't mow the lawn or refrigerate the food or anything like that. So a lot of people And I'm going to try and talk while I type so bear with me A lot of people will learn programming and then there exists this mentality to add everything humanly possible into a code Class or an application of some kind and it's just the wrong way of doing things because it makes it unmaintainable So we're going to say whoops Temp converter Call this T and we're going to say int value And let's say 32 And let's go ahead and convert to just this raw value Let's say we got this from a temperature sensor on a hardware device or something like that and I'm going to say Celsius to Fahrenheit And we want to say t and we want to say Celsius to Fahrenheit And because we followed this pattern most of this should be dead simple. We can just copy switch these around Fahrenheit to Celsius Bang simple easy to use Dead simple to maintain does exactly what it says it's going to do and if we run this it should give us fairly accurate results Hmm I think I'm not an expert, but I think Fahrenheit to Celsius is zero. There we go