MVC in Drupal - Create Beautiful Code

Track: 
Coder
Experience: 
Intermediate

Take your Drupal skills to the next level!

Drupal’s awesome framework lets us accomplish a lot, quickly.
However, too much code gets crammed in the .module file, which might make it difficult to follow and update.

Taking a holistic MVC approach allows for beautiful, well-organized code. Your colleagues will love you!

In this session you will learn:
1. All about MVC (Model-View-Controller)
2. How to apply it to Drupal module design
3. How to make your code super-easy and a pleasure to work with

Any time remaining will be spent on Q&A.

Intended audience: 

Drupal developers with intermediate and advanced experience.

Also great for developers looking to transition to Drupal and learn about the Model-View-Controller code pattern.

Questions answered by this session
Question 1: 
What is the Model-View-Controller pattern
Question 2: 
How to apply MVC to Drupal module design
Question 3: 
How to make your code super-easy and a pleasure to work with
Question 4: 
Comparison of typical Drupal module vs an MVC influenced Drupal module
Question 5: 
How to develop MVC modules as a team, including my own experience on working with an offshore team in India!
2.85185
Your rating: None Average: 2.9 (27 votes)

Comments

Posting code

Could you post some of the code which you will be demonstrating before hand? I have no idea how to evaluate this session without seeing an example of an MVC module.

Re: code

This session will go in to MVC theory as it applies to Drupal, as well as how to plan your modules. We'll discuss how to plan your Coding Project as much as possible, yet leave it flexible, agile enough to grow with the ever-changing requirements.

You'll be left with very clean, expandable code. Following these conventions will avoid "spaghetti" code and be able to easily abstract your code in cache, or other wrapping requirements as they're discovered.

Code samples will be provided at the session.

For more information on Model-View-Controler, see http://en.wikipedia.org/wiki/Model%E2%80%93View%E2%80%93Controller

Example of an MVC module structural overview:

bookstore/
bookstore/models/
bookstore/models/modelBooks.inc
bookstore/models/modelBookLibrary.inc
bookstore/models/modelBookSearch.inc
bookstore/theme/block-book-info.tpl.php
bookstore/theme/block-book-related.tpl.php
bookstore/theme/content-book-library.tpl.php
bookstore/bookstore.admin.inc
bookstore/bookstore.module
bookstore/bookstore.info
bookstore/bookstore.install

In this case, the bookstore.module is acting as a controller.
Models will be loaded following a demonstrated factory pattern.
Models are broken down by very specific type and functionality. Each function will have the minimum amount of functionality and absolutely no SQL code will be allowed in the module files. The system strictly adheres to DRY (Don't repeat yourself - http://en.wikipedia.org/wiki/Don%27t_repeat_yourself) principle.

Sincerely,
Eric W. Spector, MSc, PMP
http://www.ericwspector.com

Diamond Sponsors

 
Palantir.net
VPS NET

Platinum sponsors

 
workhabit
Trellon

Gold Sponsors

 
Drupal Connect
HotDrupal.com
Microsoft
Chapter Three
Treehouse Agency
Duo
NorthPoint