我要封我知道不应该被使用作为基类的所有类? [英] Should I seal all classes I know shouldn't ever be used as a base class?

查看:133
本文介绍了我要封我知道不应该被使用作为基类的所有类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该封,我知道,即使没有切实的性能或安全问题,或者这只是将多余的内容?不应该被使用作为基类的所有类

Should I seal all classes I know shouldn't ever be used as a base class even when there are no tangible performance or security concerns, or is this just adding cruft?

推荐答案

一个类是可扩展实现该功能,它可以扩展 - 这就像类的任何其他功能的特性,应该像一个来处理,没有从方法不同。所有功能应通过精心被认为以确保它们满足了客户使用该功能的目标。功能需要进行设计,实施,审查了安全问题,调试记录和维护。

A class which is extensible implements the feature that it can be extended -- that's a feature like any other feature of the class, and should be treated like one, no different from a method. All features should be thought through carefully to ensure that they meet the goals of the customer using the feature. Features need to be designed, implemented, reviewed for security problems, debugged, documented and maintained.

所有的这些花费精力和努力,通常需要金钱的支出。谁的钱你花?他们可能对你是否应该这样做功能,或者不发表意见。

All that costs effort, and effort usually requires the outlay of money. Whose money are you spending? They might have an opinion on whether you should do this feature or not.

基本上,你有三种选择:

Basically, you have three choices:

1)花的钱,让你有信心,这是正确的,稳健的,安全的,满足用户需求做功能。

1) Spend the money to do the feature so that you have confidence that it is correct, robust, secure and meets user needs.

2)做以上都不是,但无论如何运送功能,并希望出货的无意中,迅速实施,未经检验,无证,无人维护与未知的安全隐患功能不会伤害你,你的雇主或您的客户。

2) Do none of the above but ship the feature anyway and hope that shipping an undesigned, rapidly implemented, untested, undocumented, unmaintained feature with unknown security risks doesn't harm you, your employer or your customers.

3)密封类。开封后来如果发现(1)是正确的选择。

3) Seal the class. Unseal it later if you find that (1) was the right choice.

我说,(3)是物有所值。我总是封印每节课我写的不是设计为可扩展性。

I say that (3) is good value for the money. I always seal every class I write that was not designed for extensibility.

这篇关于我要封我知道不应该被使用作为基类的所有类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆