Chapter 7. Better Living in Objectville: Inheritance and Polymorphism
Plan your programs with the future in mind. If there were a way to write Java code such that you could take more vacations, how much would it be worth to you? What if you could write code that someone else could extend, easily? And if you could write code that was flexible, for those pesky last-minute spec changes, would that be something youâd be interested in? Then this is your lucky day. For just three easy payments of 60 minutes time, you can have all this. When you get on the Polymorphism Plan, youâll learn the 5 steps to better class design, the 3 tricks to polymorphism, the 8 ways to make flexible code, and if you act nowâa bonus lesson on the 4 tips for exploiting inheritance. Donât delay, an offer this good will give you the design freedom and programming flexibility you deserve. Itâs quick, itâs easy, and itâs available now. Start today, and weâll throw in an extra level of abstraction!
Chair Wars Revisited...
Remember way back in Chapter 2, when Laura (procedural programmer) and Brad (OO developer) were vying for the Aeron chair? Letâs look at a few pieces of that story to review the basics of inheritance.
LAURA: Youâve got duplicated code! The rotate procedure is in all four Shape things. Itâs a stupid design. You have to maintain four different rotate âmethods.â How ...
Get Head First Java, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.