P
P
Pavel2018-09-09 00:08:07
PHP
Pavel, 2018-09-09 00:08:07

What is the best way to implement the browser pattern to link view and view in mvc?

Hello, in order to gain practical experience, I decided to write a small mvc bike. Smart heads and Wikipedia in particular argue that it is desirable to use the browser pattern to implement the interaction between the model and the view. The question arose whether to use the built-in SplSubject / SplObserver interfaces or use your own implementation, examples of implementations are also on Wikipedia . Based on them, I came to the following conclusions.
In favor of their implementation they say:

  • I don't need the detach method, the script will die on its own when it reaches the end, it's PHP
  • I can better specify the type of the passed class for the notify() method using a Model instead of a SplSubject, as other classes can also implement this interface

Also in the process of writing, another question arose. I will have static views that do not need a model at all (forms for example). They don't need a notify() method per se. Based on this, they should not be implemented as browsers at all and you need to share them somehow with the views that need it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg Viktorovich, 2018-09-10
@KpuTuK

If because "it is written in Wikipedia" that it is not necessary to apply.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question