Seal design Reactions

Sealing a method or a class prevents subclasses from overriding it.

In C# you use the keyword sealed, in Java you use the keyword final. Languages like C# and C++e consider methods sealed by default (you unseal them with the virtual keyword) other languages (such as Java) leave methods unsealed by default.

There is quite a lot of controversy about whether sealing is a good idea. Those with a DirectingAttitude like be very careful about what classes and features are available for overriding and confine extenders to only override things they consider safe. Those with an EnablingAttitude take the view that they cannot predict what extenders may need to do and thus shouldn't deny them the flexibility - extenders can override whatever they like, but they have to take the responsibility to be careful. As in most things I tend to being an enabler.


Links
home
bliki
feed 
Translations
Japanese
Spanish
Korean
Chinese
Thai
Categories
agile
design
dsl
leisure
refactoring
ruby
thoughtWorks
tools
uml
writing
Blog Roll
ThoughtBlogs
TW Alumni
Nicholas Carr
Steve Cook
Brian Foote
Simon Harris
Gregor Hohpe
/\ndy Hunt
Ralph Johnson
Patrick Logan
David Ing
Brian Marick
Jeremy Miller
Jimmy Nilsson
Samuel Pepys
Keith Ray
Johanna Rothman
Kathy Sierra
Dave Thomas