The excerpt discusses the recommendation to seal classes in .NET for design clarity and adherence to OOP principles, while noting that benchmark tests reveal non-sealed classes perform slightly better. Despite this, the author maintains sealing classes not meant for inheritance is essential for robust class design. An EditorConfig setup for checking this is also mentioned.
Tag: CA1813
General Performance Tip: Performance Impact of Sealing Attributes
When customizing attributes, Microsoft and I both advise sealing them for clarity and performance. However, benchmark results show sealing attributes to be marginally less performant, with both outcomes indicating a memory allocation of 24 bytes. Despite this, I maintain that sealing non-inheritable classes is essential for robust class design.
