The following sections of this BookRags Literature Study Guide is offprint from Gale's For Students Series: Presenting Analysis, Context, and Criticism on Commonly Studied Works: Introduction, Author Biography, Plot Summary, Characters, Themes, Style, Historical Context, Critical Overview, Criticism and Critical Essays, Media Adaptations, Topics for Further Study, Compare & Contrast, What Do I Read Next?, For Further Study, and Sources.
(c)1998-2002; (c)2002 by Gale. Gale is an imprint of The Gale Group, Inc., a division of Thomson Learning, Inc. Gale and Design and Thomson Learning are trademarks used herein under license.
The following sections, if they exist, are offprint from Beacham's Encyclopedia of Popular Fiction: "Social Concerns", "Thematic Overview", "Techniques", "Literary Precedents", "Key Questions", "Related Titles", "Adaptations", "Related Web Sites". (c)1994-2005, by Walton Beacham.
The following sections, if they exist, are offprint from Beacham's Guide to Literature for Young Adults: "About the Author", "Overview", "Setting", "Literary Qualities", "Social Sensitivity", "Topics for Discussion", "Ideas for Reports and Papers". (c)1994-2005, by Walton Beacham.
All other sections in this Literature Study Guide are owned and copyrighted by BookRags, Inc.
Composition is a term relevant to computer science in the context of object-oriented languages such as Java. In object-oriented programming, the act of creating one object from a relationship between several other objects is known as composition.
A non-computing example is that of an airplane. An airplane has engines, wings, tires, wiring, and a myriad of other items that comprise it. To describe an airplane, one could not simply say wings. An airplane is an amalgamation of all the component parts, which are related to each other in the functional sense of being part of the whole. In computer science, composition relates the parts of a whole to both create a new object and to relate the components to the whole and to each other in a meaningful way.
Composition is also known as aggregation. It is different from inheritance, which is another means of establishing relationships between classes. In inheritance, one object is an extension of another object. For example, the class apple is an extension of the class fruit.
In composition, the components of the encompassing object are classified as separate classes. The encompassing object is itself a class. In the airplane example, two classes would be airplane and wings. These two classes are related, with wings being what is termed a field to the airplane class.
Composition is useful when coding specifications that relate objects have a "has" or "have" nature. The objects have a relationship that can be described as one object composing the other object. In contrast, inheritance is more of a "is a" relationship. When a programmer anticipates altering the code that would affect the relationship between the classes of concern, composition can be the technique of choice, as programming can be accomplished with greater ease.