Yurttas/PL/OOL/docs/ool.html

From ZCubes Wiki
Jump to navigation Jump to search

object-oriented languages


  • The object-oriented paradigm not only deals with programming, it is also a paradigm for designing systems, in particular large and complex ones. Object-oriented design tries to make software systems easier to maintain and change. In addition, it eases the reuse of existing software.
  • The key idea in object-oriented design is to focus on the objects in the system, rather than on the system's functions. Objects are less vulnerable than functions to changes in the system specification.
  • The most important concepts in object-oriented languages are objects, classes, inheritance, polymorphism and dynamic binding.
  • A class describes a category of objects. It contains a description of the internal variables of the objects and the operations that can be applied to the objects.
  • If a new class is defined, it can inherit variables and operations from an existing base class. Inheritance leads to a hierarchy of classes, where each class inherits from its ancestors in the hierarchy tree. With multiple inheritance, a class can inherit directly from multiple base classes.
  • Some languages treat classes as types. They apply type-checking rules similar to those for subtypes. Since a class can redefine the behavior of an operation inherited from one of its ancestors, viewing classes as types may not always be appropriate. Other languages regard classes as objects.
  • The class hierarchy makes it easy to support polymorphic procedures, which take the parameters of different types. The normal static type-checking rules (if any) can be used for polymorphic procedures.
  • With dynamic binding, if an object executes an operation, the run-time class of the object determines which code will be executed. With static binding, the choice is made at compile time. For object-oriented languages, dynamic binding is to be preferred: if a class has redefined an operation, it is often an error to execute the original operation defined in an ancestor class.
  • In most object-oriented languages, variable always contain pointers to objects. Other languages are less pure, and also store scalar data in variables or let the programmer decide.
  • An important issue in object-oriented programming is when to use inheritance. Inheritance is usually appropriate if the 'is-a' relation holds between two classes, but not if the 'has' relation applies.