Object-oriented programming (OOP) is a way of organizing
the code in a program by grouping it into objects. The term
object
in
this sense means an individual element that include information
(data values) and functionality. When you use an object-oriented
approach to organizing a program you group particular pieces of
information together with common functionality or actions associated
with that information. For example, you could group music information
like album title, track title, or artist name with functionality
such as “add track to playlist” or “play all songs by this artist”.
These pieces are combined into a single item, an object (for example,
an “Album” or “MusicTrack”). Bundling values and functions together
provides several benefits. One key benefit is that you only needing
to use a single variable rather than multiple ones. In addition, it
keeps related functionality together. Finally, combining information
and functionality allows you to structure programs in ways that
more closely match the real world.
|
|
|