MVC in Vanilla JavaScript

后端 未结 2 1313
闹比i
闹比i 2021-02-03 14:34

I\'m at the point now where i really want to organize my code in a way that makes it more scalable and manageable. i want to get a better understanding of the MVC architectural

2条回答
  •  清酒与你
    2021-02-03 14:55

    The first truth is that View and Controller are - in most cases - very close. Sometimes even the same. And that isn't neccessarily bad. If you have a table, select a row, then click on a button that will change the data in the selected row, the button will obviously part of the View (you see data) and the Controller (you change data). There are better examples for this, I'm sure...

    The second truth is that you will find almost as many opinions on MVC as there are people ;)

    But personally, I'd advise you not to follow some design pattern slavishly. MVC is good starting point to design your code, but in the end, your code needs to be fast, stable and maintainable. And, you (and your team) have to be comfortable with the code. If you end up with code that follows the MVC pattern, fine. If not, also fine. At least that's my view on that.

提交回复
热议问题