Object-oriented programming is a concept that swept through university computer science departments in the 80s and the production software community in the 90s. Like "modular programming" before it and "Internet programming" after it, OOP was a subject of some debate. Now, the concepts of modular programming are universally accepted, and many of the concepts of OOP are widely accepted, although some objections to the OOP paradigm remain.
Other People Are Reading
The Basic Idea of OOP
In OOP, computer programs are the interaction of "objects." An object has "instance variables" and "methods." The instance variables record values associated with the object. Methods are functions that involve some aspect of the object. In a game program, there might be an object called "space ship," which has instance variables like fuel amount. A method might be "fire torpedo." Space ships might belong to a "class" of objects called "moving objects." Asteroids also belong to this class. Running the program consists of the objects sending "messages" to each other.
The Advantages of OOP
The first advantage to the objects concept is that all code that has anything to do with space ships are located in one place. Another advantage is that objects can possess inherent attributes from the class they belong to; for example, space ships and asteroids both might have an XY position because all objects that belong the class of moving objects have an XY position. Writing code is often easier because you can conceptualise it as something happening to an object. Another advantage is that OOP makes large programs more manageable. If all windows belong to a hierarchy of windows classes and all the code that refers to a particular window is with that window object, all window manipulations can be written as the transferring of simple messages.
The Disadvantages of OOP
Not all programs can be modelled accurately by the objects model. If you just want to read in some data, do something simple to it and write it back out, you have no need to define classes and objects. However, in some OOP languages, you may have to perform this extra step. Another disadvantage is that if you force the language into the OOP concept, you lose some of the features of useful languages like the "functional languages." Another disadvantage is that one programmer's concept of what constitutes an abstract object might not match the vision of another programmer. The objects often require extensive documentation.
The Future of OOP
The future of OOP probably lies with languages like Ruby and Lua, in which the object concept is built into the language and is not always explicitly controlled by the programmer. Ruby, for example, treats everything like an object, including strings, numbers, your program and the contents of the directory you are currently in. You almost never need to declare anything to be an object. You are free to use the language any way you want: as an OOP, as a functional language, as a procedural language or even in ways that mix up the modalities.
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for