What are the advantages of using an MVC framework

2019-01-22 09:56发布

I am writing a comparison between 3 technology options for building our new website:

  • Wordpress
  • Drupal
  • An MVC framework

The boss is sure we should use Wordpress, but the site will be big, with many sections, subsections, pages, and complicated templates.

I'm finding it easy to compare WP + Drupal, but not so easy to state the additional advantages (over Drupal) of using an MVC framework.

So far I have:

  • Custom data storage, content types, semantics
  • APIs / REST
  • Separation of logic / UI
  • Convention, code structure

(Obviously some of the benefits will be different depending on the type of project. In this case it will be a large portal for a museum, with potential for some social stuff for visitors)

11条回答
Luminary・发光体
2楼-- · 2019-01-22 10:09

I reckon Drupal is MVC. Drupal uses a theming system which is your views and a menu system which is your controller. The modules are your models. Sure, the menu is fragmented into various modules but it's still basically MVC right?

查看更多
爱情/是我丢掉的垃圾
3楼-- · 2019-01-22 10:15

I would advise you strongly against WordPress, it is wonderful for sites with some static pages and one blog/news section, but I made a bilingual product website based on WP 2.2 and it was a major PITA with lots of hacking and writing database-reaching code into the template to make it possible.

Now I have been developing in Drupal and it is really better for larger projects (although it takes more time to set up a simple blog compared to WP) - it has wonderful modular architecture that allowed me to solve any request/problem so far by writing a module instead of hacking the core.

As for MVC/Drupal: have look what Drupal does, if you can get your result by modifying Drupal, then it is great and will save you a lot of time by not having to code the usual stuff (user registration, input sanitization, robust form handling and validation, theming infrastructure, storage abstraction, web services abstraction layer (Services module) and so on...).

Against Drupal: inherently slow, due to modular (I'm rendering a list of items, let's call all modules that implement theme_list to find out if they want to modify it) architecture, so if you are making next twitter, get a fast MVC framework instead. And caching of content for registered users still needs lot of work to be effective (a tagged cache should be in core), so sites when users are usually logged in can be slow.

查看更多
我命由我不由天
4楼-- · 2019-01-22 10:22

It's difficult to compare a CMS (e.g., Drupal, WordPress) with an MVC framework because they are in different categories.

To specifically answer your question about the advantage of an MVC framework over a CMS, the advantage of an MVC framework is simply that it allows you to design the exact web app you need from the ground up.

As for your particular situation:

Using an existing CMS such as WordPress or Drupal would be an excellent idea if they fit your needs. It avoids reinventing the wheel, saves you time, and CMSs can be quite user-friendly (to varying degrees). If you plan to delegate the task of content updates to a non-technical user, then it might be prudent to choose a novice-friendly CMS rather than spinning your own with an MVC framework, possibly resulting in an app that requires more technical expertise to maintain.

If, however, you envision that the website will require a lot of custom business logic that would be difficult to implement within the constraints of a CMS, then you might need to use an MVC framework.

查看更多
相关推荐>>
5楼-- · 2019-01-22 10:22

I would say the advantage of using an MVC framework to roll your own instead of using WP or Drupal are:

  1. You only code what you need. WP and Drupal are gonna have lots of stuff you don't need sitting on your server.
  2. The developers understand the whole codebase because they've written it from scratch - making it easier to maintain later.
  3. WP is a big codebase (I don't know about Drupal) as soon as you require something that isn't supported by either CMS you are going to have to dig around a lot of code.
  4. Wordpress' separation of logic / UI sucks - I mean really sucks.
  5. More flexibility. CMSs are great as you don't try to make them do something they weren't intended to do - then they become a pain.

If you are going to push for an MVC framework then you need to look carefully at which you would choose - they are not created equal. Some of them will place restrictions on your code and website layout in the same way a CMS would.

I guess it's really down to how complex the requirements are and how well a CMS or framework will meet those. For relatively simple content delivery it may be an option to write your own lightweight MVC and build upon that.

查看更多
趁早两清
6楼-- · 2019-01-22 10:26

Thanks everyone for your answers. I made the case for using a Framework or Drupal, but it was decided that we should go with Wordpress, or at least start building on Wordpress and see how it goes.

FWIW here are the notes I came up with:

WORDPRESS / MU

http://wordpress.org/ http://mu.wordpress.org/

A personal publishing tool, blogging platform

  • PHP +
  • Many available widgets +
  • Multi-author support / workflow +
  • Social features (BuddyPress) +
  • Integration (BBPress etc) +
  • Easy, common +
  • Simple UI +
  • Able to manage multiple blogs (with WordPress MU) +
  • Only 2 content types (post or page) -
  • Not a real "CMS" / blog mentality -
  • Inflexible heirachy (no sections) -
  • Limited semantics -
  • Limited template choices for authors -
  • Messy code -
  • Security / exploits -

DRUPAL

http://drupal.org/

A content management framework, CMS construction kit, tools to build sites. For 'non programmers' to build websites, building blocks

  • PHP +
  • Made for big sites / portals +
  • Social features built in (each user has own profile/log, extensible) +
  • Page type selection/config by authors (block system) +
  • Scope for structured data / semantics +
  • Multiple content types (press releases, news articles, blog posts, etc.) +
  • Good community / tools +
  • Blank canvas +
  • Many features +
  • Good image handling +
  • Complex UI -
  • "Black box", very abstract code, learning curve! -
  • Customizing / theming is difficult -

FRAMEWORK

It allows you to design the exact web app you need from the ground up

  • Extensible +
  • Control of semantics, data storage +
  • APIs / Data / REST / Web services +
  • Current, modern tools, cutting edge +
  • Separation of logic/presentation (MVC design pattern) +
  • Convention - structured code, workflow +
  • Reuse/combine content +
  • Allows development of multiple UIs without touching business logic codebase +
  • Robust API / standards / patterns +
  • DRY (don't repeat yourself) +
  • Learning curve -
  • Need to design a custom UI -
  • Overkill? (depending on goals) -
查看更多
家丑人穷心不美
7楼-- · 2019-01-22 10:26

You can't really compare WP or Drupal and MVC framework. What you can do is to decide whether to use an existing content-management system or roll out your own and compare ROI, TCO, development cost, etc.

查看更多
登录 后发表回答