0

I m studying Magento2, and have reviewed one of the documentation where every design pattern which is used in Magento2 is explained with extending and Interface. Right now I only know basic of what Inreface is.

This is the tutorial I am referring to - https://www.maxpronko.com/magento-2-development-design-patterns/

1 Answer 1

2

First of all, interfaces are not extended by classes, they are implemented by classes.

An interface is just a set of public methods that have no body (code).
An interface describes how an object (class) behaves but without specifying the implementation.
It is used to avoid creating tightly coupled classes.
one class can just depend on an interface and it lets you provide the actual class that implements the interface easily.

Basically and interface provides a separation of how something is used from how it is implemented.
You can find here a simple example on how to use an interface: https://phpenthusiast.com/object-oriented-php-tutorials/interfaces

1
  • Thanks for the answer. What I basically want to do is, I want to code seperate modules using every design pattern. Can you share a good documentation to do so?
    – Tester
    Commented Nov 6, 2018 at 9:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.