Ramblings on technology with a dash of social commentary
RSS icon Email icon Home icon
  • What is ORM and why should you use it?

    Posted on May 11th, 2010 phpguru 2 comments

    I’ve been asking myself this question a bit more lately so I wanted to find some answers. Nowadays, ORM typically stands for Object Relational Mapping, and less commonly, Object Role Modeling, although the two concepts are related. Mainly I am curious about some of the new ORM implementations for Kohana 3, namely Sprig (based on Django) and Jelly.

    The first page on this topic can be found over at Stack Overflow.

    On the StackOverflow page is a link to this post by Glenn Block on the MSDN blog. I found it a bit surprising that this particular post hadn’t been voted on by any other Stack Overflow members as I found it an insightful and succinct explanation of why you might want to consider using ORM.

    I noticed another topic that comes up in relation to ORM is DM, the Domain Model pattern, and DDD, Domain Driven Design. I thought this post entitled DDD – why bother? was an interesting take with a terrific example illustrating the benefits of an ORM system.

    This post was inspired by Koes.

     

    2 responses to “What is ORM and why should you use it?” RSS icon

    • I enjoyed reading both of those articles they both make some good points.
       
      As a web developer I’ve come to the conclusion that DDD takes up to much time to be a viable approach to the development of the type of projects I work on. As I understand it, in DDD the aim is to codify the problem domain (a supermarket, for example) using objects to represent each thing in the problem domain (people, products, payment systems etc), then to represent the interactions between those things (the business processes) with service objects (checkout process?) which themselves might make use of further entities and services. All of this careful design makes it much for easier you to test a system and ensure it does exactly what you need it to do but it also takes allot more time to create when compared with alternative approaches to development.
       
      Eric Evans in his book “Domain-driven design” describes the development of an air traffic control system. Exactly the sort of system where a bug can cause major problems or even the loss of life. With this type of project your client will be more than willing to pay for you to ponder on the relationship between entities and to ensure the system is as well designed as possible. I know that for the majority of projects I have worked on there is usually pressure to just get a ”working” system in as short as time as possible and so pure DDD is not an option. That said I think its still possible to make use of some of the concepts of DDD even if your not able to be a DDD purist.

    • Thanks for the reply, Kevin!

      I had the good fortune of getting to work with some great Java programmers back at Frankel & Co in Chicago who taught me Apple WebObjects. One of the best things about WebObjects is EOModeler, a gorgeous UI for modeling your business objects. EOModeler lets you export both MySQL database schema and Java class files representing your EOModels, and then WebObject’s Application Context manages change graphs on those objects. Basically you can load( ) and save( ) and whatever has changed gets updated in the database. It’s pretty elegant, actually, and it saves tons of time. I realize that isn’t exactly the same thing as DDD, but I think it’s a good example of how to apply the concepts.


    Leave a reply

    Spam Protection by WP-SpamFree