ed our queue by making it private, 5:13 we can swap that out whenever, as long as the public methods still do and 5:17 return what they're expected to. 5:20 So there you go. 5:23 Best practices are always going to tell you to favor composition over inheritance. 5:24 And I hope you can start to see why. 5:28 Inheritance is basically saying bin is a queue, and 5:31 composition is saying the bin has a queue. 5:35 In my experience, I'd suggest that you start by composing and 5:39 move to inheritance if you end up writing all of the methods. 5:43 So you might be wondering, this is all great Craig, but 5:47 what does this have to do with testing? 5:50 Well, remember that mantra of testing that I keep repeating? 5:51 Testing enforces best practices. 5:55 Composition is one of those best practices. 5:57 Let's take a quick break and 6:00 I'll show you why composition is a great testing solution and how it helps solve 6:01 another programming problem and helps bring forward another best practice. 6:05 The single responsibility principle. 6:09
You need to sign up for Treehouse in order to download course files.Sign up