There is another way to move closer to the Open Closed Principle ideal that might be cleaner in the end.
最后,还有一种更靠近开闭原则的方式需要说明。
I would recommend that you treat the Open Closed Principle as a design vector rather than an outright goal.
我建议你将开闭原则作为一个设计方向而非一个完全的目标。
If a class that uses an abstraction has to downcast to a specific subclass in one section, you're not following the Open Closed Principle.
如果在某一部分中,一个抽象了的类必须向下转换为特定的子类,那么你就没有遵循开闭原则。
You may not always manage to write code that satisfies the Open Closed Principle in every aspect, but even moving partway there can be beneficial.
你可能并非总是试图写一些在各个方面都满足开闭原则的代码,但是即使只进行到中途也是非常有益的。
By following the Open Closed Principle with the order processing rules, I've made it much easier to add new types of order handling logic to the system.
通过在订单处理规则上遵循开闭原则,我使得在系统中添加新类型的订单处理逻辑容易得多。
As I said earlier, the most common manifestation of the Open Closed Principle is using polymorphism to substitute an existing part of the application with a brand new class.
如果我前面所说的,使用开闭原则最通常的做法就是使用多态去用一个全新的类替换程序中现存的一部分。
The design follows the Open Closed Principle if you can extend the system by swapping out implementations of IDataSource without making any change to the BusinessProcess class.
如果你可以通过实现IDataSource对这个系统进行扩展并且不对BusinessProcess类做任何的修改,那么这个设计就遵循了开闭原则。
In following the Open Closed Principle, I want to be able to write a class or a method and then turn my back on it, comfortable that it does its job and I won't have to go back and change it.
在遵循开闭原则的过程中,我期望能够写出一个类或者方法,在以后我回过头读它的时候,会很舒服地看到它能完成它的工作并且我也不需要再修改它。
You'll never reach true Open Closed nirvana, but you can inch much closer by rigorously following the related Single Responsibility Principle: a class should have one, and only one, reason to change
你永远也达不到真正的开闭天堂,但是通过严格地遵循与之相关的单一责任原则:一个类应该有并且只有一个更改的理由,你可以非常靠近地接近它。
I'd like to start with a discussion of the Open Closed Principle and other related ideas popularized by Robert C. Martin in his book, Agile Software Development, Principles, Patterns, and Practices.
我喜欢以讨论开闭原则和其他由robertC.M artin在其著作《敏捷软件开发,原则,模式和实践》中所倡导的相关主题作为开始。
Banks closed on Friday afternoon and did not open again until Monday morning.
银行星期五下午关门,直到星期一早上才会再开门营业。
Geigl herself believes that with cooperation between bench and field researchers preserving fossils properly could open up avenues of discovery that have long been assumed closed.
Geigl 本人相信,如果研究人员和野外研究人员通力合作,妥善保存化石,可能会开辟长期以来被认为封闭的发现途径。
I closed my eyes and made a wish: to be as open-minded as my family and my new friend.
我闭上眼睛,许了一个愿:我要像我的家人和新朋友一样豁达。
Progress computation will be based on the number of open and closed work items which is usually less significant.
进度计算将基于打开和关闭的工作项数量,此数量没有多大意义。
Take the course of an interview for example, closed and open questions may both be used, in any combination.
以一场面试的过程为例,封闭式问题和开放式问题可以联合使用。
The Open Dialogue was closed, according to the site, on June 26.
网站表示,开放化对话已于6月26日结束。
A flash empurpled all the facades in the street as though the door of a furnace had been flung open, and hastily closed again.
火光一闪,把街旁的房屋照成紫色,好象有个火炉的门突然开了一下,又立即闭上似的。
If you open a different folder, the currently open folder is closed automatically.
如果您选择另一个文件夹,则当前打开的文件夹将自动关闭。
If you decide to copy instead, then this may be done while the project is open or closed.
如果你决定复制,那么在项目打开或关闭时都可进行。
GCC is the cornerstone of development in both the open source and closed source worlds.
无论是开源开发还是闭源开发,GCC都是开发的基础。
Regardless of whether the Windows were open or closed, the rate measured around the infant seat in the rear exceeded accepted thresholds for children by the US Environmental Protection Agency.
无论车窗是打开与否,在车厢婴幼儿位置的烟的比例都超过了美国环保局为儿童制定的允许标准。
Figure 4 above showed a report example tracking notes by note status (for example, open, pending, closed).
上面的图4显示了一个报告实例,它按照标注状态(例如打开、暂挂、关闭)跟踪标注。
Closed vs open certificate issuing systems.
封闭证书发布系统和公开证书发布系统。
Prosser draws a distinction between the "open web" and Facebook's closed system.
Prosser把开放式网络和Facebook的封闭式系统区分了开来。
And they could not get loans to keep their businesses open. Many factories closed.
商人无法归还银行贷款,他们也得不到银行的贷款来维持他们的业务,许多工厂关门了,大量的人失业了。
Because the airport was closed, the pilot had to land the plane in an open field.
由于机场关闭,飞行员只得将飞机降落到一片旷野里。
Equally important, OER open up a previously closed commercial value chain system in ways that empower learners and teachers.
同样重要的是,OER以授权学习者与老师的方式,揭开商业价值链以前的封闭系统。
But it certainly is something that will have great potential to open up more closed societies or help open up.
但是毫无疑问的是,它会具有开启,或者辅助开启封闭社会大门的巨大潜力。
We can distinguish between open and closed applications.
应用程序分为开放型和封闭型。
应用推荐