Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Yo-yo problem
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
In [[software development]], the '''yo-yo problem''' is an [[anti-pattern]] that occurs when a programmer has to read and understand a program whose [[Inheritance (object-oriented programming)|inheritance graph]] is so long and complicated that the programmer has to keep flipping between many different class definitions in order to follow the control flow of the program. It is most often seen in the context of [[object-oriented programming]]. The term comes from comparing the bouncing attention of the programmer to the up-down movement of a toy [[yo-yo]]. Taenzer, Ganti, and Podar described the problem by name, explaining: "Often we get the feeling of riding a [[Yo-yo|yoyo]] when we try to understand one of these message trees."<ref name="ECOOP 89">{{cite web|last=Taenzer|first=David|title=Problems in Object-Oriented Software Reuse|url=http://www.ifs.uni-linz.ac.at/~ecoop/cd/papers/ec89/ec890025.pdf|work=ECOOP 89: Proceedings of the Third European Conference on Object-Oriented Programming, 1989|publisher=Cambridge University Press|access-date=22 March 2013|author-link=Problems in Object-Oriented Software Reuse|author2=Ganti, Murthy |author3=Podar, Sunil |pages=33β34|year=1989}}</ref> Most practices of object-oriented programming recommend keeping the inheritance graph as shallow as possible, in part to avoid this problem. The use of [[object composition|composition]] instead of [[inheritance (object-oriented programming)|inheritance]] is also strongly preferred, although this still requires that a programmer keep multiple class definitions in mind at once. Deep hierarchies are a [[code smell]] and a symptom of [[Subclassing (OOP)|sub-classification]] for [[code reuse]].<ref>{{cite web |title=Code Smell 11 - Subclassification for Code Reuse |date=30 October 2020 |url=https://maximilianocontieri.com/code-smell-11-subclassification-for-code-reuse |publisher=hashnode |access-date=18 January 2021}}</ref> More generally, the yo-yo problem can also refer to any situation where a person must keep flipping between different sources of information in order to understand a concept. There are several [[Refactoring|code refactor]] techniques to flatten these hierarchies without compromising the overall behavior. Object-oriented design techniques such as documenting [[layer (object-oriented design)|layer]]s of the inheritance hierarchy can reduce the effect of this problem, as they collect in one place the information that the programmer is required to understand. ==See also== *{{section link|Design Patterns|Introduction, Chapter 1}} *[[Complexity]] What it means for a system (of any sort) to be complex *[[Hrair limit]] The suggestion that humans can entertain at most approximately seven concepts at once *[[Implementation inheritance]] *[[Inheritance semantics]] *[[Virtual inheritance]] (object-oriented programming) *[[Code smell]] ==References== {{Reflist}} [[Category:Object-oriented programming]] [[Category:Anti-patterns]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Cite web
(
edit
)
Template:Reflist
(
edit
)
Template:Section link
(
edit
)