L
L
Legebocker2017-08-26 19:16:35
Programming
Legebocker, 2017-08-26 19:16:35

How to implement COP in C++?

I was reading articles on Habré, and then I came across an article about COP. I was like: WHAT? update something in the function, you need to make 100500 changes, and in the COP just fix the component. Also, in the COP you don’t need to make a complex class hierarchy like in OOP "
I thought maybe advertising too? I look like Habr, there seems to be no nonsense about dropping fat, drinking a glass at night.
So my pointless epilogue is over, and here are the questions?
1. Is COP as good as it is praised?
2.How can I implement this in C++ or will I have to settle for OOP?
PS
K component
O objective
P approach

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stanislav B, 2017-08-26
@S_Borchev

and the case is not
K component
O oriented
P programming
?

A
asd111, 2017-08-27
@asd111

What you call "COP" has long been used in OOP and is called Composition over inheritance. This is when composition is used instead of inheritance.
For example, inheritance would be like this:

class Person {
     String name;
}
class Employer : Person {
    BigDecimal salary; 
}

and with the composition it will be like this:
class Person {
     String name;
}
class Employer {
    Person person;
    BigDecimal salary; 
}

Read about design patterns in OOP. There is a lot of interesting and practically applicable.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question