“所有公共方法都应该是虚拟的” - 是或否/专业&缺点 [英] "All public methods should be virtual" - yes or no / pros & cons

查看:66
本文介绍了“所有公共方法都应该是虚拟的” - 是或否/专业&缺点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在组建一些类库,供许多其他的b $ b项目使用。


我们团队的一些成员坚持认为;所有公共方法都应该是虚拟的

以防万一需要更改任何内容。这非常违背我的b / b
本能。有人可以为我提供一些可靠的设计指南吗?


提前致谢....

I''m on a team building some class libraries to be used by many other
projects.

Some members of our team insist that "All public methods should be virtual"
just in case "anything needs to be changed". This is very much against my
instincts. Can anyone offer some solid design guidelines for me?

Thanks in advance....

推荐答案

如果你计划将它们衍生出来,那么很明显。


如果它是一个密封的类,那么它的无意义和编译器(如果没有)

应该防止在密封的班级中使用虚拟语言。


Ken Brady <柯*********** @ thomson.com>在消息中写道

news:O
If you plan on them to be derived from then yes obviously.

If its a sealed class, then its pointless and the compiler (if it doesnt)
should prevent having virtuals in a sealed class.

"Ken Brady" <Ke***********@thomson.com> wrote in message
news:O


************** @ TK2MSFTNGP12.phx.gbl ...
**************@TK2MSFTNGP12.phx.gbl...
我正在组建一些类库,供许多其他项目使用。

我们团队的一些成员坚持认为所有公共方法都应该是
虚拟以防万一需要改变任何东西。这非常违背我的直觉。任何人都可以为我提供一些可靠的设计指南吗?

提前致谢....
I''m on a team building some class libraries to be used by many other
projects.

Some members of our team insist that "All public methods should be virtual" just in case "anything needs to be changed". This is very much against my
instincts. Can anyone offer some solid design guidelines for me?

Thanks in advance....



"肯布拉迪 <柯*********** @ thomson.com> skrev i meddelandet

新闻:O
"Ken Brady" <Ke***********@thomson.com> skrev i meddelandet
news:O


这篇关于“所有公共方法都应该是虚拟的” - 是或否/专业&amp;缺点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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