We Should Care About OCP…

关闭类以集中精力开发新功能,提高生产力并降低成本。通过在类中创建扩展点为软件用户提供灵活性,并为未来需求预留空间,同时避免不必要的功能开发。开放依赖项以扩展不受控制组件的行为,缩短反馈周期。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[size=medium]…because closing our classes allows us to focus on new functionality. It makes us more productive.

…because more productivity means less waste. Less waste means less cost. Less cost means more money. More money is the goal.

…because when we create extension points in our classes we provide flexibility for the consumers of our software.

…because when we create extension points in our classes for our own needs, we create extension points the future needs of future customers without succumbing to YAGNI.

…because it lets us extend the behavior of components outside of our control. Even if we do control dependencies, it’s a shorter feedback cycle to add novel functionality when said dependencies are open to extension. Shorter feedback cycles equate to more productivity and, well, you know.[/size]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值