课程: Programming Foundations: Design Patterns
今天就学习课程吧!
今天就开通帐号,24,100 门业界名师课程任您挑!
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…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
-
Revisiting inheritance1 分钟 30 秒
-
(已锁定)
Limitations of inheritance4 分钟 18 秒
-
(已锁定)
Trying interfaces2 分钟 28 秒
-
(已锁定)
Get inspiration from design principles3 分钟 37 秒
-
(已锁定)
Programming to an interface1 分钟 32 秒
-
(已锁定)
Applying the principles4 分钟 36 秒
-
(已锁定)
Exploring the strategy pattern1 分钟 59 秒
-
(已锁定)
Why HAS-A is better than IS-A2 分钟 4 秒
-
(已锁定)
Challenge: The Strategy pattern2 分钟
-
(已锁定)
Solution: The Strategy pattern46 秒
-
-
-
-
-
-
-