J
J
Junior932019-09-26 14:54:17
OOP
Junior93, 2019-09-26 14:54:17

Can composition and inheritance be called a pattern?

Hello, tell me plz, if they ask me what patterns I know, can I answer Composition and inheritance or are they not patterns?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Fedorov, 2019-09-26
@Maksclub

A pattern is a rather utilitarian thing, a certain clear sequence or description of connections so that one or another instrument can be repeated, easily identified and conveyed.
Composition is an abstract concept that classifies what needs to be built in some other way than inheritance. Delegate and arrange so that polymorphism manifests itself through a number of objects that are not related in the inheritance chain.
Inheritance is about the fact that objects inherit an interface / state, there is no interaction scheme here, it is quite direct: A inherited from B and that's it. But there is a lot hidden inside.

H
hack504, 2019-09-26
@hack504

These are not patterns. Here are the patterns: Guardian, Visitor, Opportunist, Substitute, Loner, Builder, Planner, Observer, etc.
But it's better, of course, to know and apply composition and inheritance than to spend time on a code reference.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question