课程: Programming Foundations: Design Patterns

今天就学习课程吧!

今天就开通帐号,24,100 门业界名师课程任您挑!

Get inspiration from design principles

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…

内容