课程: Programming Foundations: Design Patterns
今天就学习课程吧!
今天就开通帐号,24,100 门业界名师课程任您挑!
Understanding the open-closed principle
- [Instructor] So where do we go from here? Let's begin by getting some insight from our next design principle, the open-closed principle. This principle says that classes should be open for extension but closed for modification. What does that mean? Well, think about our current design for the coffee shop. We know in the future we'll need to support new beverage types and new condiments but that means we'll have to modify existing code, and that's exactly what we don't want. We want to leave our design open for new beverage types and condiments but closed in the sense that we don't want to touch existing code. Let's look at this principle in a little more detail. Again, the open-closed principle says that code should be open for extension but closed for modification. If we can do that, we have flexibility and maintainability because we can add new behavior but without the risk of introducing new bugs into the code we've…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
-
-
-
-
(已锁定)
Creating chaos with inheritance4 分钟 12 秒
-
(已锁定)
Understanding the open-closed principle2 分钟 49 秒
-
(已锁定)
Extending behavior with composition2 分钟 29 秒
-
(已锁定)
Understanding the decorator pattern2 分钟 23 秒
-
(已锁定)
Using the Decorator pattern5 分钟 6 秒
-
(已锁定)
Challenge: The Decorator pattern40 秒
-
(已锁定)
Solution: The Decorator pattern1 分钟 22 秒
-
(已锁定)
-
-
-