restriction - When to restrict a class from extending a class? -


is there point in programmer's lifetime restrict class extending class? example don't want package extend box.

yes. in java call final class. in c# call sealed class.

it done because cannot predict many ways consumer might extend class, prevent having design class account possible ways might extend it, seal , require consumer use composition instead of inheritance.

further reading
why many of framework classes sealed?


Comments

Popular posts from this blog

design - Custom Styling Qt Quick Controls -

Unable to remove the www from url on https using .htaccess -