Skip to content

.

└── charlotteresnick.dev

└── a blog about my journey to software engineer

Week Four - Let's Chat About ORMs

General, ORMs2 min read

Project One behind me, this week was all about SQL, psql, ORMs, Express, Node, and APIs. Basically a back end fest.

So this was really my first venture into persisting data. Previous to this week, everything we had been working on had no concept of storing data; every time a page was refreshed, the back end was wiped clean. And now data’s saved! And now I can save data!

The SQL section of this week was a breeze. I had taken a summer course on SQL at a hacker space in the Mission last year, so I wasn’t a complete stranger. That said, it had been a hot moment since I had actually done anything with it. Nonetheless, it came back to me pretty quickly and struggling was kept to a minimum.

My favorite lesson this week was on ORMs. Class flew by and I had a couple Holly Moley brain moments where I really nerded out and got excited about the prospect of being able to build really cool things in the future. That said, the concept of an ORM seemed pretty intimidating at first. But it became a lot clearer as the day progressed. Here’s what I know so far:

Object Relational Mappers are libraries that allow a programmer to write queries--simple, extremely complicated, and everywhere in between--using any programming language they’d like, as opposed to SQL. Interacting with a database becomes much less complicated.

Like most things, there are pros and cons to ORMs. Like I mentioned, ORMs allow programmers to write in their preferred language, which is great! Switching between, say, MySQL and PostgreSQL also becomes much easier. And some ORMs come with a bunch of neat out of the box features. Plus, SQL is a powerful language, thus SQL queries are as well; an ORM’s queries, oftentimes, will be better than those a novice SQL programmer wrote themselves. But SQL wizards can probably write fantastic queries that are far more performant than those an ORM can generate.

As far as ORM cons go, configuring an ORM is a pain. I wouldn’t know from experience or anything. From the looks of the Google troubleshooting I did along the way, I don’t think I’m alone. Also, as cool as ORMs are, I think it’s important to truly understand the why. Would I use an ORM having little knowledge of databases and SQL? Probably not. And I think General Assembly agrees (our lecture on ORMs was saved for Friday after we had done a lot of psql, SQL, and Express routing heavy lifting).

And that’s a wrap on week 4! I’m off to do weekend homework.

© 2020 by charlotteresnick.dev. All rights reserved.
Source