V
V
vvafree2015-07-17 11:55:20
Programming
vvafree, 2015-07-17 11:55:20

What is substitution in OOP?

Hello. Substitution in object-oriented programming, tobish overrideng is a redefinition. Override = polymorphism. Tobish substitution = polymorphism.
So the question "The concept of substitution in OOP" is the question "The concept of polymorphism in OOP"?
Thanks to everyone who replies =)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
pi314, 2015-07-17
@vvafree

Polymorphism is one of the three fundamental principles of the OOP paradigm.
Overriding (also "overriding" or "overriding" methods) is a generic name for the mechanism provided by the PL to support the application of this principle when designing class hierarchies.
The specific details of the implementation of the mechanism may differ (as, for example, in Java and JS), but the essence of the so-called. OOP remains the same. But in C, for example, there is no such mechanism at all, but this does not prevent (just does not help!) Writing object-oriented code in this language .
So, if overriding is meant by "replacement", I would not identify the goal and the means to achieve it so broadly :)

D
Dmitry, 2015-07-17
@EvilsInterrupt

Perhaps you are talking about this:

class Фигура:
  virtual void нарисоватьСебя() = 0;

class Круг : public Фигура:
  virtual void нарисоватьСебя() {
  // код рисующий круг
  }

class Квадрат : public Фигура:
  virtual void нарисоватьСебя() {
  // код рисующий квадрат
  }

You have many figures, but each looks different. However, each one can be drawn. It turns out that by studying a set of objects, you select properties and actions common to all and form an "Abstraction", in this example, a "Figure". When you have generalized and formulated the abstraction in code, it is time to describe the details about the Circle and the Square. When you write drawYourself() for a square, you are overriding the code written in "Shape". Thus you move from the general to the particular.

A
abs0lut, 2015-07-17
@abs0lut

Yes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question