by codegeek · 12y ago · 0 comments
user = User.objects.create_user('name', 'email', 'pwd')
user.save()
In 2 lines of magical code, we are able to create a user object and make sure we are able to save it in the database without worrying about a lot of things. This is great for rapid app building. But what is really happening behind the scenes ? Do you really understand the flow for user.save(). How would you do it without this abstraction ? If you don't understand the core, you will never be able to become a great developer.So my advice overall is to learn the core by writing stuff from scratch as much as possible and really understand how things work. Then, pick a framework and do the same. So even though you will write crappy bad quality code, you don't need to release that in production. Win-Win here.
Even if you throw out of the ORM and go with writing SQL queries by hand, do we need to understand how the database will parse the SQL, how it stores the data on disk and how it executes the query?
The main reason to understand SQL when building a web application is really that the ORM doesn't provide a full abstraction due to the differences between the relational model and the OO model. If we could solve that then we could happily never use SQL again.
Yes, I've thought that, too, but it turns out that, beyond a certain relatively low level of complexity, that's a great way to produce SQL queries which take a half hour to complete.
> but helpful to understand how an ORM converts to a SQL query.
Certainly, because there's a degree of complexity beyond which your ORM's going to start getting pathological and you're going to have to fall back on querying the database directly, which see point one.
The presumption here is that everyone wants to be a great developer; this mostly isn't true, most developers simply want to complete a task and care only about how quickly they can do it.