Type generalization
Type generalization is a technique commonly used in refactoring. The idea is to draw on the benefits of object-orientation and make more-generalized types, thus enabling more code sharing, leading to better maintainability as there is less code to write. Too-general code can, however, become completely useless, leading to spaghetti code doing effectively nothing.
Type generalization refers to making more general or more abstract some subset of the traits of a specific type. A superclass has wider use than a specific subclass, and so is more 'general'.
An example of generalizing a type would be moving a method from a child to a parent class for common use by all the parent class' children, not just the original child.
Another example, in the Java programming language, would be access to an object via an interface which isn't tied into a specific implementation of that interface.
Sources and credits
This article is adapted from the Wikipedia article “Type generalization”, written by its contributors and licensed under CC BY-SA 4.0. Fathomly has changed the layout, removed citation markers, navigation and maintenance notices, and adjusted punctuation. This adapted version is shared under the same license. For references, see the original article.
Fathomly is not affiliated with or endorsed by the Wikimedia Foundation. Spotted a problem? Tell us.