the heels of selling three guitars to the rock group Augustana, Rick’s guitar business is doing better than ever—and the search tool you built Rick back in Chapter 1 is the cornerstone of his business. - He wants to do more Mandolin. => Improved Rick's Guitar application to support Mandolin.
actual implementation classes. • The abstract class defines the behavior, and the subclasses implement that behavior. • An abstract class defines some basic behavior, but in reality: the subclasses of the new abstract class add the implementation of the behavior.
instruments taken care of, we can move on to the spec classes. We need to create another abstract class, InstrumentSpec, since so many instruments have common specifications:
Instrument and InstrumentSpec classes, you create classes in Rick's application. • Adding new tools is not easy: If it's easy to change, it's how we determine whether our software is well-designed. Whenever we need to add a new tool, we have to add another subclass of Instrument • You almost always find a few new issues when you make major changes to your design and the use of these abstract classes has helped us avoid any code duplication.
search () is better, there are still some issues with subclasses, and the way addInstrument () in Inventory • Remember, we do abstract instruments because the instruments in them have subclasses.
why each instrument has a subclass • Because the Instrument class is generally generic, not a particular instrument, it's an abstract one, so we should give each instrument a subclass. • Each instrument has different properties, from which there are InstrumentSpec subclasses, so we need a specific characteristic of each instrument.
things that you will do is to let go of the mistakes you have made in your design. In Rick's search engine, it does not make sense to have separate layered classes for each instrument. • But it took them to 30 pages (and 2 parts of the chapter to find out) Why? => Because it is very difficult to change something when you are doing it. =>Code: one, look two (or more). • Design is a repetition, and we must be ready to change our design every moment needed and develop them over time and the requirements of the user. as well as learn the design of other programmers
to get a really good result. • For example, let's remove the unnecessary child classes, which will help us simplify the task and make it easier to understand.