Showing posts with label web. Show all posts
Showing posts with label web. Show all posts

2008-07-02

CMS battle: Drupal vs Joomla vs Custom Programming

In modern Content Management System (CMS) world there are two major figures - Joomla (descendant of Mambo CMS ) and Drupal. They both are open source and have large comunities with enormous amounts of extensions and themes. It's hard to choose which one to use without trying them out. As usually, there are more options - home grown custom programming or even building your own CMS (which I was once stupid enough to do). Programming from scratch is always fun and beneficial for your skills, however, if you need things up and running in no time or you don't do (or don't want to do) any programming, using a CMS is the way to go.

If you are digging for CMS comparisons and trying to decide which one is best for you, here is a quick and dirty answer - go for Drupal, you won't regret it.

Why?

After test-driving them both I've came to these conclusions:

  • Joomla is bloated, Drupal is minimal
  • Drupal is easy to use and intuitive, Joomla is confusing

That was more than enough for a minimalist like me.

Here are some statistics from CMS Matrix for a more detailed comparison. It shows that Drupal is extremely modular and Joomla has a heavy core, thus a terrible architecture. That means Joomla is hard to extend and messy under the hood. Drupal, on the other hand, looks beautiful.


Product Drupal 6.2 Joomla! 1.5.3
Last Updated 4/10/2008 5/31/2008
System Requirements Drupal Joomla!
Application Server PHP 4.3.5+
Approximate Cost Free Free
Database MySQL, Postgres MySQL
License GNU GPL GNU/GPL v2
Operating System Any Any
Programming Language PHP PHP
Root Access No No
Shell Access No No
Web Server Apache, IIS Apache
Security Drupal Joomla!
Audit Trail Yes No
Captcha Free Add On Free Add On
Content Approval Yes Yes
Yes Yes
Granular Privileges Yes No
Kerberos Authentication No No
LDAP Authentication Free Add On Yes
Yes Yes
NIS Authentication No No
NTLM Authentication Free Add On No
Pluggable Authentication Yes Yes
Problem Notification No No
Sandbox No No
Session Management Yes Yes
SMB Authentication No No
SSL Compatible Yes Yes
SSL Logins No Yes
SSL Pages No Yes
Versioning Yes No
Support Drupal Joomla!
Certification Program No No
Code Skeletons Yes No
Commercial Manuals Yes Yes
Commercial Support Yes Yes
Commercial Training Yes Yes
Developer Community Yes Yes
Online Help Yes Yes
Pluggable API Yes Yes
Professional Hosting Yes Yes
Professional Services Yes Yes
Public Forum Yes Yes
Public Mailing List Yes No
Test Framework Free Add On Yes
Third-Party Developers Yes Yes
Users Conference Yes Yes
Ease of Use Drupal Joomla!
Drag-N-Drop Content Free Add On No
Free Add On Free Add On
Friendly URLs Yes Yes
Image Resizing Free Add On Yes
Macro Language Free Add On Yes
Mass Upload Free Add On No
Prototyping Limited Yes
Server Page Language Yes Yes
Site Setup Wizard Limited No
Spell Checker Free Add On No
Style Wizard Limited No
Subscriptions Free Add On No
Template Language Limited Yes
UI Levels No Yes
Undo Limited No
WYSIWYG Editor Free Add On Yes
Zip Archives No No
Performance Drupal Joomla!
Advanced Caching Yes Yes
Database Replication Limited No
Load Balancing Yes Yes
Page Caching Yes Yes
Static Content Export No No
Management Drupal Joomla!
Advertising Management Free Add On Yes
Asset Management Yes Yes
Clipboard No No
Content Scheduling Free Add On Yes
Content Staging Free Add On No
Inline Administration Yes Yes
Online Administration Yes Yes
Package Deployment No No
Sub-sites / Roots Yes Yes
Themes / Skins Yes Yes
Trash No Yes
Web Statistics Yes Yes
Web-based Style/Template Management Yes Yes
Web-based Translation Management Yes Free Add On
Workflow Engine Limited No
Interoperability Drupal Joomla!
Content Syndication (RSS) Yes Yes
FTP Support Limited Yes
iCal Free Add On No
UTF-8 Support Yes Yes
WAI Compliant Limited No
WebDAV Support No No
XHTML Compliant Yes No
Flexibility Drupal Joomla!
CGI-mode Support Yes Yes
Content Reuse Limited Yes
Extensible User Profiles Yes Yes
Interface Localization Yes Yes
Yes Yes
Multi-lingual Content Yes Free Add On
Multi-lingual Content Integration Free Add On Free Add On
Multi-Site Deployment Yes Free Add On
URL Rewriting Yes Yes
Built-in Applications Drupal Joomla!
Blog Yes Yes
Chat Free Add On Free Add On
Classifieds Free Add On Free Add On
Contact Management Free Add On Yes
Data Entry Free Add On Free Add On
Database Reports No Free Add On
Discussion / Forum Yes Free Add On
Document Management Limited Free Add On
Events Calendar Free Add On Free Add On
Events Management Free Add On Free Add On
Expense Reports No Free Add On
FAQ Management Yes Yes
File Distribution Free Add On Free Add On
Graphs and Charts No Free Add On
Groupware Free Add On Free Add On
Guest Book Free Add On Free Add On
Help Desk / Bug Reporting Free Add On Free Add On
HTTP Proxy No No
In/Out Board No No
Job Postings Free Add On Free Add On
Free Add On Yes
Mail Form Free Add On Yes
Matrix No No
My Page / Dashboard Free Add On No
Free Add On Free Add On
Free Add On Free Add On
Polls Yes Yes
Product Management Free Add On Yes
Project Tracking Free Add On Free Add On
Search Engine Yes Yes
Site Map Free Add On Free Add On
Stock Quotes Free Add On No
Surveys Free Add On Free Add On
Syndicated Content (RSS) Yes Yes
Tests / Quizzes Free Add On Free Add On
Time Tracking Free Add On No
User Contributions Yes Yes
Weather Free Add On No
Web Services Front End Limited Yes
Wiki Free Add On Free Add On
Commerce Drupal Joomla!
Affiliate Tracking Free Add On Free Add On
Inventory Management Free Add On Free Add On
Pluggable Payments Free Add On Free Add On
Pluggable Shipping Free Add On Free Add On
Pluggable Tax Free Add On Free Add On
Point of Sale No Free Add On
Shopping Cart Free Add On Free Add On
Subscriptions Free Add On Free Add On
Wish Lists Free Add On Free Add On

Hope this helps to make a choice.

2008-04-21

Hierarchical Model View Controller - beyond MVC

I would like to share a few articles I've written back in 2005/2006 while working on an open source project - Hierarchical MVC Web framework - Claw:

Long gone post #2.

It is a common pattern in Java community (NOTE: I thought so back then, though found out that it's not really common at all), while it seems like PHP developers think there is no heaven like MVC. For those, who are interested in HMVC concepts, read this (and notice the date – quite an oldie, eh?):

http://www.javaworld.com/javaworld/jw-07-2000/jw-0721-hmvc_p.html

I haven't found a single open source PHP framework with HMVC implementation, that's why Claw was born. Are there any more of this kind? Did I miss anything? Please let me know if I did. Anyway, the long URL above would most probably be helpful for Java GUI application developers, I must say that I do not understand more than a half of that document, and never actually read the code examples carefully, so I think it is easier for me to rewrite the concepts the way I understand them and the way they work in Claw Framework. Before that you may take a glance at another Javish explanation of Hierarchical MVC here:

http://www.thecentric.com/wiki/index.php/HMVC_Tutorial

Did not get that one either, but at least it's shorter and easier to read. If you really bothered yourself to at least briefly look through that information (and shame on you if you did not, and I know you did not), you should have found out the key advantages of HMVC pattern are something like:

  • Defined intralayer communication and isolation from higher layers
  • Defined interlayer communication with minimal coupling
  • Localization of exposure to third-party code
  • Reduced dependencies between disparate parts of the program
  • Encouraged reuse of code, components, and modules
  • Increased extensibility while easing maintainability

Back to our shop architecture – here is the draft of my HMVC-inspired implementation:



For those who see a spaceship or a piece of DNA chain – bigger blocks are controllers, small tablets – controller actions (you can call them functions, methods or events if you like), black arrows show possible routes to some point of application and dotted lines show which action belongs to which controller. Now imagine the flattened requests:

http://www.shop.com/
http://www.shop.com/list/
http://www.shop.com/list/category
http://www.shop.com/list/category/4
http://www.shop.com/list/search/query.hammer
http://www.shop.com/list/category/4/product/2524
http://www.shop.com/list/search/query.hammer/product/2524
http://www.shop.com/product/2524
http://www.shop.com/list/search/query.hammer/page.4/product/2524
http://www.shop.com/list/category/25/page.42/product/11945/reviews
http://www.shop.com/list/search/query.big+fork/sort.price/order.asc/page.18/product/114/review
http://www.shop.com/product/1545/reviews

These requests would go easily without any custom mappings, URL rewriting or any other hacks you would have to do in plain old MVC. I guess these links need no special explanation, but just in case, let's examine the longest one piece by piece:

/ IndexPage – root controller for the following hierarchy
/list ListPage – controller for accessing product lists
/search ListPage::search -search action invoked on list controller
/query.big+fork ListPage::search – argument 'query' => 'big fork'
/sort.price ListPage::search – argument 'sort' => 'price'
/order.asc ListPage::search – argument 'order' => 'asc'
/page.18 ListPage::page – argument 'page' => 18
/product ProductPage – controller for single product related logic
/114 ProductPage – numeric argument => 114
/review ProductPage::review – action for adding new review


We simply form this chain element by element, so the application grows like a tree, and when you need a new branch, you simply put a tiny piece of code on top of the tree, without having to touch what has already grown big. But you have all the information inherited in the way. In our example above, when user is reviewing product #114, application is aware that he/she came from a product list page 18 of search for “big fork” by price, so when it comes to rendering navigation and layouts, you could even show search results along with review form, if you would want that for some weird reason. But it's nice to have the power, no? Those who ever developed large systems should be nodding.
How do controllers inherit data? The picture below should help you visualize the process:



As application is executed, each controller (Page) may set some variables. Child controllers can set their own, though, when you are trying to get a variable that current controller does not have, system falls back to parent and checks if this variable is not there, and if it is, the value is returned. Recursion goes to the bottom of the chain if required. And since any point you can redeclare variables, so beyond a certain point the value will be as redeclared (though parent controllers will still use the old one). As you build your application layering the controllers one upon another, at the end of what I call “chain reaction”, application collects the flattened set of variables and passes them to final view (which is flattened after playing the puzzle within same reaction):



This is simply a composite view, with parts and layers, that each controller inherits from the parent and can manipulate it, rewrite it, etc. Final view is rendered only when chain reaction is over, and view layers are “flat” in final position. This is the time when variables are stamped in, so before final controller hits the breaks, nothing is rendered – this lazy kind of work saves resources.

Model View Controller and Enterprise Applications

I would like to share a few articles I've written back in 2005/2006 while working on an open source project - Hierarchical MVC Web framework - Claw:

Long gone post #1.

At this era of frameworks popping out of nowhere, crowds of people being obsessed with Ruby on Rails and Zend releasing their own framework, it's really a headache to choose the right tools for the right job. One thing is for sure – every good web developer knows – Model-View-Controller pattern is the right way to go.

Yes, MVC is a great pattern, no doubt that it's necessary to separate your business logic from graphical representation and database implementation. However, let's try implementing the following application using MVC:



What we have here is a simple structure of online shop, where users can choose the goods either by browsing categorized list of products, or by using the search feature. Product items may also have customer reviews, and visitors may add their own opinion for every product in the store. In real world you application structures are far more complicated than this one, but still, let's try modeling the MVC approach for this application.

Model

As a great fan of Object Oriented Programming, I would use a Domain Model pattern for the business logic part of the application. My components would be:

Category – tied up to the Product with many-to-many relation

  • getProducts - retrieves a list (an array) of Product objects, which belong to the Category
  • getTitle - retrieves a string with Category title
Product – tied up to Category with many-to-many relation, and to Review with one-to-many relation
  • getCategories - retrieves a list of Category objects, which the Product belongs to
  • getTitle - retrieves a string with Product title
  • getPrice – retrieves a price value object (to make it simple – just float value)
  • getReviews – retrieves a list of Reviews for this Product
  • addReview(Review) – adds a Review for this Product
Review
  • getAuthor – gets the author of Product review
  • getContent – gets the text
  • getRating – gets rating given to Product by the reviewer
After having my Domain Model ready, I would take care of persisting it to Database. Here you are on your own. I would go for Active Record implementation this time, as my model is dead simple. For more sophisticated cases Active Record would be a pain in the rear, so I would go for a serious ORM tool (such as Propel – http://propel.phpdb.org for PHP or Hibernate – http://www.hibernate.org for Java). So, we're done with our Model. No sweat! Time for the letter V in the MVC triad.

View

Personally for me, View part of any web application is the major headache, especially when you have got a State of Art prototype to follow, and your designer often complains that checkbox should be two pixels down in Internet Explorer, but four pixels up in Opera. Anyway, despite these annoying things implementing View in the MVC triad is a piece of cake. I prefer a Two Step View even in simplest situations, so I am going for it. There would be a plain HTML skeleton with empty body as the second step layer for each View, and the first step is upon the Controller.
The following problem may occur if you would want the following things done properly within your Views for current application architecture – How to Back-link Product items with the list they were accessed from. It may be the Category List, Search Result List or none, if user went directly to product. Of course, user can use browser back button, but what if he/she goes to read Product Reviews, afterwards, add a new one, then returns to Product View? I believe back button will not help you here. You could store required information in session or cookie variables, however, this adds unwanted complexity and introduces possible new bugs. Avoiding this functionality may annoy visitors, forcing them to repeat their search again, perhaps navigate through result pages to reach the point they were at. For now, let's keep our mind off this and see how to deal with Controllers.

Controller

Finally, we are about to liven up our application with user request processors, referred as Controllers. Normally, MVC frameworks use a Front Controller as one entry point for the whole application, which routes URL requests, invoking Input Controllers and their actions. How could the Controller architecture look with our current Online Shop application? It would probably end up like this:

Front Controller – the entry point which routes URL requests

Front
  • index – the action that is taken when user comes directly to your application root. Main page layout is set for View, some promo Product links attached, navigation menu for Product categories and search input
  • search – this is the action that search input leads to. It processes search query and forms a list of results, paging is involved.
  • category – here we have a list of Products by category, perhaps there would be options to sort items by title, price, ascending and descending order, also, including paging.
Product
  • index – action is taken when user views the product. Some identification should be passed along with request variables.
  • reviews – displays current product reviews
  • review – displays a form where user can add the review for the Product. It also processes form variables, validates them and writes the review to database.
Simple as that. We have mapped out our application with merely two Input Controllers! Let's see how some user URL request scenarios may look like and what would they map to:
  • / -> Front/index
  • /search -> Front/search (may display a search form with advanced options)
  • /search?q=sledgehammer&page=3 -> Front/search (third page of search for “sledgehammer”)
  • /search/sledgehammer/3 -> Front/search (same third page of search for “sledgehammer” with custom request rewriting – I will go on using this style of requests from now on)
  • /category/tools -> Front/category (category type is tools, first page of listing)
  • /category/food/price/asc/4 -> Front/category (food Products listed by price in ascending order, fourth page of navigation)
  • /product/2455 -> Product/index (would display information of product #2455)
  • /product/2455/reviews -> Product/reviews (displays all reviews for product #2455)
  • /product/2455/review -> Product/reviews (displays a form where user can submit her/his own review)
Everything looks nice, this scheme would work perfectly well, but the problem is – there are certain points where you loose the flow. Likewise, imagine you were at /search/sledgehammer/3, and clicked on a lovely “Almighty Masher”, which linked to /product/2455. You've certainly wanted some reviews of this great tool in action, and followed the “User Reviews” link to /product/2455/reviews. After reading for a while, you discover that “Almighty Masher” is just one overpriced piece of junk, and you want to fall back to the search you were doing. Well, back button is fine, click one, click two, and we're back on the track! But what if your application required users to be logged in to read the reviews? When you happily click “User Reviews” link, an unexpected screen appears asking you to log in, or even worse, offering you to register. Wise applications usually redirect user back to where he was going after logging in / registration process. It does not break the back button, you say? Perhaps, but it sure decreases the comfort of navigation (especially if your registration process had 7 steps).

Another disadvantage is that if you are in /product/2455/reviews and you still want to see the information of your product in the Reviews View, you will have to pull out the Product using the ID which comes along with request. And you will have to do this in /product/2455/review as well, or the reviewer may simply forget the exact title of the item. That leads to code duplication – every method of Product input controller must have some lines that find the Product. It's like shooting darts to different areas on the target – each area gets hit on it's own, as you cannot hit for both “10” and “15” with single shot due to the fact that there is no union on the target grid. With MVC pattern developers usually map the native applications tree (or in sophisticated cases – graph) hierarchy into plain two-dimensional grid enriched with variables. It can be compared to mapping Objects with many references, collections and relationships into Relational Database Management System. It's simple when your application is Farmer Joe's personal guest book, but what if you're working on something as large as E-bay or Amazon.com? You would sweat cats and dogs and spend months on writing meta-data and configuring your ORM tools to make your beautiful hierarchy broken down to the grid. And you would sure have to do the same with your controllers. But do you have to? I would not take this burden upon my shoulders, as my choice is Hierarchical MVC.