Should classes still be sealed as a recommendation? [closed]

给你一囗甜甜゛ 提交于 2019-12-23 08:02:12

问题


I know this is "technically" a duplicate of this question. Should I recommend sealing classes by default?

But I'm asking it again because apparently the recommendation has changed1 with the times though I can't find anything in the last few years about it or about the fact that more and more people are recommending AGAINST sealing classes now thanks to the improvements in testing (which was one of the main reasons), processor speed (speed difference now is negligible), etc.

I'm trying to find out what the latest guideline is for weather or not to mark classes as sealed.

1 Essential C# 6.0 (5th Edition), Mark Michaelis (co author Eric Lippert):

"In general, marking a class as sealed is rarely done and should be reserved only for those situations in which there are strong reasons favoring such a restriction. In fact, leaving types unsealed is increasingly desirable, as unit testing has become prominent because of the need to support mock (test double) object creation in place of real implementations."

This is hardcopy proof as the others are all word of mouth.

来源:https://stackoverflow.com/questions/34827443/should-classes-still-be-sealed-as-a-recommendation

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