Everyone is recommended to teach / use / pray at MVC.

I encounter it mainly in Jumla, then an allergy to the Nuba application developed: for example, I went to the template.php file, and it says:

 <?php $this->view->printHTML(); ?> 

And accordingly, I am looking for this function by file, three more files are included in it, require in a loop and the like. I understand that this is not "pure MVC", but when the template is used everywhere, even if the main framework is not adapted to this + provokes such a mess from the extra files, it makes me nervous.

And actually the question: all my life, as it turned out recently, I used a facade or a simple code pair (function / class / require) + a template for simple modules. For a pair of coder + coder, the second seems ideal to me.

How is MVC better and are there more adequate patterns for teamwork ?
Or is "MVC" just another cool abbreviation for indirect brain massage for employers?

  • The topic is sooooo holivarna, about the "idiotic" use of MVC - this is not a MVC problem - this is a problem of the developer’s qualification and / or sore brain :) - Zowie
  • The problem is rather that I observed such a number of idiotic ways of using only MVC =) Especially when they try to cooperate with the class-template. - Sh4dow
  • 2
    I watched only with MVC because I quote “everywhere and everyone is recommended to teach / use / pray at MVC” :) Accordingly, everyone tries to write with its use, without even understanding why it is necessary at all and how to write it normally . - Zowie
  • one
    The same can be attributed to the OOP term (everyone is just used to it) - avp
  • So pure OOP is also not always suitable for the task. But in principle I like this analogy, because the same people everywhere thrust the same people with the same result) - Sh4dow

6 answers 6

Yolka-Zelenka, what am I reading here!?

Guys. If you encounter bad code and there is a bad programmer in it

And, accordingly, I am looking for this function through files, three more files are included in it, require in a loop and the like.

This is not a problem. MVC architecture is a problem of crooked hands, dull heads and misunderstandings.

MVC is very convenient.

If it is interesting to learn about the time frame for creation, then with the help of the YII Framework, the admin panel for the site can be done in about an hour to 3 hours. Let it not be "Oh, how beautiful," but it is fully functional.

MVC is cool!

From the programmer, provided he uses the Framework, all that is needed is a logical presentation of his project and an understanding of the principles of the MVC architecture.

For most frameworks, the first demo for noobs make the creation of "BLOG", for what? Well, usually, in a good case, almost all web developers make their blog, and here once - and raise it on any framework in 10-30 minutes, then turn it off. It will check for input characters by small manipulations, and check for filling and so on, so forth.

Who faced, again, I repeat, with the Nubov codes of the guys, pry these hands from those who wrote, and do not swear on the architecture. If you did not feel it or did not understand it, this does not mean that it is bad. Rather, you are not competent in the matter, not the architecture, because huge projects are being developed on it, including high-loaded ones.

Pluses MVC can be listed for a long time, there are also disadvantages.

Say, how long will you write caching on your resource? Well, probably spend exactly a day or two, this is with a good set of circumstances, and I’m not sure, because you need to apply it to all the code. And in MVC, you simply add, God forbid, 2-10 lines to the code and you are glad that your resource has less database, sends more cache to the user, everyone is happy, the host is happy. The server is resting.

I can write and paint for a long time, but hammering into the wall is wrong. Noobs are dug into the wall, I really hope that they are sooooo small quantity of them on this resource.

Teach materiel, read about MVC architecture, learn, and try to understand with examples!

Good luck.

  • who put +1? Thanks I want to say :) - Artem
  • one
    Eh) I would also speak, but it's a pity dinner ends. MVC is, of course, true, but if we are talking about php, which means about the web, then in real life, where the application changes only part of the content from page to page, it is an order of magnitude more agile to use the so-called HMVC. Truncated The dinner is over :-( - Vitaly Kustov
  • @ Vitaly Kustov wrote beautifully :) - Artem
  • 3
    You can write beautifully without OOP, on functions))) - Yoharny Babay
  • one
    And this is also true, especially with the advent of closures. - Zowie

I will answer whatever language and platform regarding the feasibility of MVC as such. I recently participated in the development of an application (such as a virtual keyboard), almost all of the functionality of which came down to the user interface. The application was written on WPF using MVVM (this is not MVC, but close enough to this). Why was the MVVM approach chosen? Because it greatly facilitates testing: minimizing the view allows testing the model and the controller separately. Type testing is limited to external viewing of the interface. It costs a lot.

  • one
    Personally, in MVC, the Controller part strains, if, for example, everything is clear with the model and the outlines, then the controller is an extremely hazy thing. And they write it, often, "whoever he wants" - Zowie
  • Well, on the same php there is a divine die(var_dump($this)) , which can at any time see the status of variables. Here with other languages ​​- everything is completely different, at least scripted to evaluate. And in some only the functional approach works at all) But the example is good, thank you, although I’m still not sure that mvc is not superfluous here. - Sh4dow
  • @ Sh4dow what language is it? Yes, and I (like thin =)) hint - for MVC it ​​is NOT NECESSARY to use OOP - Zowie
  • That I commented on the answer, which is "whatever language and platform." It is interesting, but I would like it for php, because he has a bunch of his, let's say, features) - Sh4dow

Scolding MVC judging by one of the implementations is the same as saying that all people are criminals because you know one person, and he is a criminal. Before you drop someone off the ladder, you should read the principles of this approach, and if you are 100% sure that you are able to come up with something better, or you can better implement the basic principles of MVC, do it! After judge!

Historically, I worked more with the vBulletin forums, but this month I had to work with the new version of IPB, which is based on the principles of MVC. So, now I want to drop vBulletin from the ladder of developers. Because if you write an application, mixing the style of the function, the classes, and each page is its own php file. For example, there is a user page, etc. That will throw you g * vnom. But vBulletin, it's a completely different thing! Because it is the development of Jelsoft Enterprises Ltd! At the moment, looking at the tools that php gives us, I am not seeing something more acceptable. And you can break the wood with any approach. That's not difficult.

ps Do always high quality! Bad by itself it turns out!

  • And you try, like me, after Joomla to work with the bitrix)) The impressions are exactly the same, only the objects of impression are the opposite) - Sh4dow
  • For me personally, neither the first nor the second indicator has ever been))). If you already praise someone else, then probably modx developers do not like everything there, but I think it is normal. Just their overruns no more))). But in general, I understand what you mean))) - Arni

To be honest, my opinion - the MVC architecture is crap. Sorry for the sharpness, but when faced with template sites built on this architecture ... I just want to spit, and the creator of this miracle is thrown off the stairs, or the roof of a 20-story house.

Personally, my opinion:

  1. If you can use HTML + JS templates (for Ajax requests that will edit the template) - use.

  2. Almost any code can be written based on 3 patterns: (Facade, Decorator, Adapter). Of course, not everywhere will drive, but as practice shows ........

  3. Always use OOP. This will facilitate the work of someone who will write code after you ... and if you write at least 100,000 lines without OOP, then you will be able to disassemble your code for a long time.

  • four
    However, a poorly written OOP code will be parsed even longer. - avp
  • WARNING! Holy war! If strictly judged - OOP does not exist in most languages, it is just an extension of the procedural approach ... - timka_s
  • The PLO is actually an extension of the procedural approach: DDD - Zowie
  • @ Stanislav Komar Well, I agree with you on most points, the only thing is yes, it should also be used wisely. Well (and adequately) usually look like a few “library” files with procedures and functions and already a clean op for modules-extensions with native templates (without any kind of smarti there and so on). Oh, and mvc in js is generally a separate comedy, not even very impudent comrades spit on it) - Sh4dow
  • one
    In js MVC this is IMHO bullshit ... - Zowie

If you are interested in learning about the timeframes of creation, then using the YII framework, the admin panel for the site can be made from about an hour to 3 hours.

Just then, everyone who writes this way is modestly silent that before that it is necessary to spend a couple of months studying the very YII framework

    Of course, I apologize wildly, but I will add mine too:

    MVC and other scrubs are a real KAMASUTRA for developers. I also recall the fable of Comrade Krylov's Quartet.

    Well, you - think for yourself, to have or not to have.