A Path Less Taken

Breaking with convention in a very conventional fashion. Powered by WordPress

"What would you attempt to do if you knew you could not fail?"
Dr. Robert Schuller

Tuesday, February 9, 2010

Category: PHP Development Tags: Author: JJ 0 Comments

Object Relational Mapping (ORM) tools are software products designed to allow developers to work with relational database management systems (RDBMS) in an object oriented and database agnostic way. Their primary goal is to make the developer’s work easier and free them to focus on higher value aspects of their solutions. As a hobbyist programmer I have a limited amount of time to give to my projects. In the last year this realization has pushed me to look at development tools that can increase my productivity in the limited time available. Leveraging an ORM solution seemed like a natural step in that progression.

As a PHP developer my list of options is currently limited to ORM tools built for PHP. So far I have tried two of these. Although there were a number of things that I liked about each solution, there was at least one aspect of each that I did not like. I decided to cast my net wider and look at other PHP ORM solutions. As I did more research I began to realize there are notable differences among the key products in the space as well as a number of “upstart” competitors that are rising up to fill any perceived gaps. With a number of high profile and niche products to consider I quickly realized that choosing between them would be difficult.

This led to the post you are now reading. I decided that rather than simply compare features of the existing products I should put together a list of what is important to me in an ORM solution. If I can define which features I want (from most to least important) and which features I don’t want then I can use the list to compare against each solution. The one that best matches my list is the one I’ll pursue next. So without further preamble, here is my list. Note that it is my list “today” and it will likely change or evolve as I learn more about ORM solutions.

Things I Want (Must Haves)

  • Open Source – I’m not opposed to a commercial solution, but for now I want open source.
  • Strong Community – There is strength in numbers.
  • Good Documentation – Quick Start Guide, User Guide, Reference Manual, User Contributed Cookbooks, etc.
  • Easy to Install – You would be surprised at how many people just assume you can figure it out yourself.
  • Easy to Use – I don’t want to struggle with an ORM. The classes and methods should be intuitive.
  • Fast – Performance that is within 20% to 25% of hand coded PDO based solution.
  • Good Query Builder – The underlying query builder should be easy to use directly and the methods should behave in an obvious and straight forward way.
  • Native SQL – The ability to easily use SQL to populate result sets for so called “edge cases.” Pet peeve: Most of the notable work developers do is edge cases. If it were easy, anybody could build it.
  • Data Form Marshaling – Why should I have to catch data from a form when the form should be built on an ORM model?
  • Built In / Custom Validation – Should have a simple to configure and use validation strategy.

Things I Would Like (Nice to Have)

  • Strong Typing – Makes life easier when working with databases.
  • Form Decorators – Model awareness of web form decorator class or classes and ability to return a default decorator from a method.
  • Integrated Security – Stop XSS, SQL Injection, etc.
  • Flexible Architecture – Ability to have inherited model objects or contained model objects.
  • Automatic Model Validation at Design Time – It would be helpful if there was a global option to turn on or off model validation. This way a model would check to make sure the underlying table was appropriate at design time, but would not waste cycles doing this check in production.

Things I Don’t Want (Bad ORM)

  • Automatic Model Generator – Not sure why, but code generators just strike me as a bad idea. My main issue here would be changes can’t be replicated to the generated files without overwriting manual changes that you might have made.
  • Gimmicks – I don’t want features for the sake of features. I want a well thought out solution that is not bloated with every possible feature anyone could ever want.

No comments found. Please enter a comment if you have a question or contribution.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">