Thursday, April 21, 2016

ORMs

Thursday, April 21st 2016

ORMs
ORMs, in a nutshell, wrap around a database providing a bridge of communication between the programming language and database commands. This allows you to use the programming language that you're already using as the means to query and interact with the database rather than having to use the query language.

Pro's:
Firstly, ORM's allow you to manage different databases with ease. For example, if your using MySQL and Neo4j, the commands to retrieve data are going to be very different. The ORM will automatically translate the commands using one language to multiple different query languages, depending on the configuration. Additionally, this allows less emphasis placed on the syntax of the query language and more emphasis placed on the logic of the query. Lastly, because less code is written because you only have to write the code in one language, it makes the system more robust by reducing the amount of code written.

  • Scalability and Flexibility with multiple databases
  • Allows developers to focus on logic rather than syntax
  • More robust codebase

Con's:
ORMs are not lightweight. Because ORMs are tasked with translating programming language to the query language (in addition to other tools), ORMs are often heavy packages making them less portable. Additionally, ORMs require you to understand them and can often lead to an extra step in the development process - you or your team may not be familiar with DB frameworks like Mongoose, which adds an additional step between you and your finalized product. Additionally, its abstracts the DB which is great for people who know what they are doing but not so great for newbies that don't realize that some commands (like for loops) can be a drag on performance.

  • Heavy weight
  • Adds another step in the development process
  • Requires configuration
  • Easy to abuse if not fully understood

TLDR:
Use ORM's to help with scaling efforts, keeping your backend code/logic written in one language and more robust code. Do not use ORMs for simple, small projects. If you have a team of devs that are god-like query masters, then ORMs may be just a redundant step and may not be prefered by the dev team.

References
http://www.artima.com/intv/abstract3.html
http://www.yegor256.com/2014/12/01/orm-offensive-anti-pattern.html
http://stackoverflow.com/questions/448684/why-should-you-use-an-orm

No comments:

Post a Comment