Yo-yo problem
Encyclopedia
In computer science
Computer science
Computer science or computing science is the study of the theoretical foundations of information and computation and of practical techniques for their implementation and application in computer systems...

, the yo-yo problem is an anti-pattern
Anti-pattern
In software engineering, an anti-pattern is a pattern that may be commonly used but is ineffective and/or counterproductive in practice.The term was coined in 1995 by Andrew Koenig,...

 that occurs when a programmer has to read and understand a program whose inheritance graph
Inheritance (object-oriented programming)
In object-oriented programming , inheritance is a way to reuse code of existing objects, establish a subtype from an existing object, or both, depending upon programming language support...

 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 often happens in object-oriented programming
Object-oriented programming
Object-oriented programming is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction,...

. The term comes from comparing the bouncing attention of the programmer to the up-down movement of a toy yo-yo
Yo-yo
The yo-yo in its simplest form is an object consisting of an axle connected to two disks, and a length of twine looped around the axle, similar to a slender spool...

.

Most practices of object-oriented programming recommend keeping the inheritance graph as shallow as possible, in part to avoid this problem. The use of composition
Object composition
In computer science, object composition is a way to combine simple objects or data types into more complex ones...

 instead of inheritance
Inheritance (computer science)
In object-oriented programming , inheritance is a way to reuse code of existing objects, establish a subtype from an existing object, or both, depending upon programming language support...

 is also strongly preferred, although this still requires that a programmer keep multiple class definitions in mind at once.

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. See Design Patterns, Chapter 1 summary, for additional information.

Object-oriented design techniques such as documenting layer
Layer (object-oriented design)
In object-oriented design, a layer is a group of classes that have the same set of link-time module dependencies to other modules. In other words, a layer is a group of reusable components that are reusable in similar circumstances...

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

  • Complexity
    Complexity
    In general usage, complexity tends to be used to characterize something with many parts in intricate arrangement. The study of these complex linkages is the main goal of complex systems theory. In science there are at this time a number of approaches to characterizing complexity, many of which are...

     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)
    Virtual inheritance
    Virtual inheritance is a topic of object-oriented programming. It is a kind of inheritance in which the part of the object that belongs to the virtual base class becomes common direct base for the derived class and any next class that derives from it...

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK