Should I use MVC both on client and server?

后端 未结 3 1825
孤独总比滥情好
孤独总比滥情好 2021-02-10 21:08

I\'ve decided to use MVC Pattern on my site. So, now I use Backbone.js framework on my site. All actions on my site are ajaxy, so server only gets data from db, and

3条回答
  •  悲&欢浪女
    2021-02-10 21:34

    No, you don't need to use it server-side, but it will help with organization / separation of application and business logic. Depending on the scale of your application, that could help tremendously in the future.

    The key is just making sure you organize your backend code well, otherwise you will end up with a monolithic and/or difficult-to-maintain codebase.

    Edit in response to OP's edit:
    Server-side views would contain your HTML and any JavaScript that may or may not make requests to the server. This assumes that you are actually using PHP to build the pages that a user navigates to.

    If you have a static html page that builds itself using AJAX requests, then you may not need to use server-side views at all. Your controllers would more than likely be outputting JSON data. If this is the case, it doesn't make models and controllers any less useful.

提交回复
热议问题