From the course: Programming Foundations: Design Patterns

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Get inspiration from design principles

Get inspiration from design principles

From the course: Programming Foundations: Design Patterns

Start my 1-month free trial

Get inspiration from design principles

- [Instructor] At this point, we really don't have a clear design direction for our duck simulator. Let's step back for a moment and review what we've tried. We started by implementing our ducks with inheritance. Only as the variety of ducks and behaviors increased, we found this didn't support our design very well. In fact, what was appropriate for one concrete subclass like the MallardDuck, wasn't necessarily appropriate for another, like the RubberDuck. This led to code duplication and actually limited our ability to make use of inheritance. We also tried using interfaces but that didn't work very well either. While using interfaces cleaned up our design from an object-oriented perspective, using interfaces totally destroyed our ability to reuse code. In fact, every concrete subclass needed to implement its own flying and quacking behavior. So, where do we go from here? Have we reached some fundamental limit to object-oriented design? Well, not at all. In fact, let's return to the…

Contents