Don's Home
Programming Languages
Object-Oriented Programming
|
Under Construction
In the 1980's Object-oriented programming (OOP) became popular, with languages like C++, Objective-C & Smalltalk. Java and C# are also Object-oriented languages.
A object-oriented program is a collection of interacting objects, which can be viewed as independent "machines" with a distinct role or responsibility. An object oriented program may be viewed as a collection of interacting objects, as opposed to the conventional model, in which a program is seen as a list of tasks (subroutines) to perform. In OOP, each object is capable of receiving messages, processing data, and sending messages to other objects. Each object can be viewed as an independent "machine" with a distinct role or responsibility. A computer language is object-oriented if they support the four specific object properties called abstraction, polymorphism, inheritance, and encapsulation. Objects consist of Methods and Data The only thing that an object knows about another object is the object's interface. Each object's data and logic is hidden from other objects. In other words, the interface encapsulates the object's code and data. A class is the blueprint from which individual objects are created. In the example below the class vehicles has a subclass Bikes which in turn has a subclass bicycles. Each class inherits commonly used state and behavior from it's superclass Data Abstraction - A superclass is an abstraction of the lower class.JavaScript: There are discussions as to whether JavaScript is an OOP. Just because a language has objectes doesn't make an OOP. Does JavaScript have the 4 properties listed above? At Is JavaScript object-oriented? - Stack Overflow, AnthonyWJones says JavaScript does provide a fairly easy means to inherit implementation via prototyping but this is at the expense of encapsulation. At Object-oriented Programming | Eloquent JavaScript, they say JavaScript has a rather eccentric take on OOP. So it seems JavaScript is not strictly an OOP.
Links:
|