Can design by contract allow me to enforce private methods

谁都会走 提交于 2019-12-13 04:57:36

问题


I can't do this with language How to enforce private method since interface methods are only public?

so can I use design by contract instead ?


回答1:


If you are interested in enforcing a particular coding style, naming conventions, or things like that you are better off implementing custom rules for tools like FxCop or StyleCop. There really aren't any features in either the C# language or the .NET environment to help you enforce such things.

However, before you go to such lengths, you should really ask yourself whether the automated enforcement of such standards are sufficiently valuable to warrant the expense and difficulty of a solution. Are you dealing with a large team (dozens of developers) or a small one? Could simpler alternatives like code reviews be a sufficient means to enforce this? How will this kind of enforcement affect the over quality of the code vs. productivity/happiness of your team? What are the consequences of these standards aren't enforced?

These are important questions to consider before implementing such enforcement.



来源:https://stackoverflow.com/questions/5766166/can-design-by-contract-allow-me-to-enforce-private-methods

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!