MENTAL
 Main Menu
 Applications
 Computer Science
 Object Oriented Programming


Object Oriented Programming
 OBJECT ORIENTED
PROGRAMMING

"The new culture of software development" (Bertrand Meyer).

"Everything is an object" (Alan Kay)

"An object has state, behavior, and identity" (Grady Booch).



The Object Paradigm

Object Oriented Programming (OOP) is a programming paradigm that uses objects as its main abstraction. An object is a software component composed of data and code. It consists of several procedures (called methods) through which the object's internal data is accessed. Objects communicate with each other by means of messages.

OOP has emerged strongly in recent times and is seen as a breakthrough in software engineering, comparable to what structured programming once was. Some have presented it as a panacea and as the "definitive paradigm". Because of its diffusion and popularization, it has been described as "The new culture of software development" [Meyer, 1990].

The software world is built primarily on OOP. This includes web applications, enterprise software, network protocols, etc.


OOP concepts
Advantages of OOP
Disadvantages of OOP
History of OOP
OOP vs. OOP (Data Oriented Programming)

In OOP, everything is an object, which integrates data (encapsulated) and code (the methods). In POD, everything is data: code and data have the same structure. This has the advantage of flexibility, since it allows to easily modify the code and to perform multiprogramming in general. In POD there is no encapsulation or polymorphism.

The most representative example is the Lisp language [Winston & Berthold, 1989], where data and code have the same structure: the list. Other examples of POD are the Awk and Sed languages [Dougherty, 1990].


MENTAL and the OOP

OOP - MENTAL comparisons
Simple examples of sharing
  1. ⟨( f(x y) = (x+y x*y) )⟩
    ⟨( g(x) = f(x 3) )⟩


    A function (g) that depends on another (f) is defined.

    g(7) // ev. f(7 3) ev. (7+3 7*3) ev. (10 21)

  2. ⟨( f(x) = (2*x + 1) )⟩
    ⟨( g(x) = (3*x + 5) )⟩
    ⟨( h(x) = (f(x) + g(x) + 7) )⟩


    In this case, a function is defined through two functions.

  3. (x = (3 5 7))
    ( y = (a ⟨x⟩ b) // ev. (a (a (3 5 7 7) b) ev. (a 357 b)
    ( z = (a ⟨x⟩∪⟨x⟩ b) // ev. (a (a (3 5 7 7 3 5 7) b) ev. (a 357357 b)


    In this case, the expression x is shared by y and by z. Changes in x immediately affect y and z.

    (x = (1 2 3)
    y // ev. (a 123 b)
    z // ev. (a 123123 b)


  4. (x = 123)
    (y = 456)
    ( z = (⟨x⟩ ⟨y⟩ ⟨x⟩+⟨y⟩) // ev. (123 456 579)


    In this case, the expressions x and y are shared by z. Changes in x and/or y immediately affect z.

    (x = 10)
    (y = 20)
    z // ev. (10 20 30)

Class example

We define a class X with which sets of integers can be created and modified, with the following methods:
  1. Create a set C.
  2. Add a number to a set C.
  3. Remove a number n from a set C.
  4. Replace a number n1 by another n2 of a set C.
  5. Delete a set C.
  6. Get the value of a set C.
The possible ways to invoke the class X are:
  1. X/(CreateConj Name Value)
  2. X/(AddNum Name n)
  3. X/(RemoveNum Name n)
  4. X/(ReplaceNum Name n1 n2)
  5. X/(RemoveConj Name)
  6. X/(ValueConj Name)
being: Specification: Examples:

Bibliography