Misplaced Pages

Type generalization

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
This article relies largely or entirely on a single source. Relevant discussion may be found on the talk page. Please help improve this article by introducing citations to additional sources.
Find sources: "Type generalization" – news · newspapers · books · scholar · JSTOR (March 2024)

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.

References

  1. Fowler, Martin (1999). Refactoring. Addison Wesley. p. 336. ISBN 0201485672.


Stub icon

This software-engineering-related article is a stub. You can help Misplaced Pages by expanding it.

Categories: