4 ms·
ORMs do that, mostly. Look at Active Record: http://en.wikipedia.org/wiki/Active_record_pattern http://en.wikipedia.org/wiki/Active_record_pattern The problem
by kemayo 16y ago
ORMs do that, mostly. Look at Active Record: http://en.wikipedia.org/wiki/Active_record_pattern http://en.wikipedia.org/wiki/Active_record_pattern
The problem with ORMs is that relational databases are complicated, and you often do wind up having to do manual SQL writing anyway if you want well-performing queries in edge cases. But for simple cases where you have a person table and need to make Person objects in your app... it works.
In fact, Rails used this as one of its big selling points, combined with convention-over-configuration. If you stuck to the naming patterns Rails preferred, it really would Just Work without you having to tell it anything beyond the names of your classes.
- adamtj 16y agoThe problem with ORMs is that life is complicated, and data describes life, so data is complicated. And abundant. SQL queries are a relatively elegant way to encode the often complicated manner in which data answers a particular question. <sarcasm>Gah! You know what I hate about building software? The programming. All those data structures are no fun! Lists and arrays and vectors and hash tables and trees, red-black trees, binary trees, b-trees, tries. Why can't we have a programming language that automagically stores all our information in simple variables and just gives me the answer I want?</sarcasm>
- rbranson 16y agoYou have apparently never used a well-designed ORM. A well-designed ORM isn't to create this magical, leak-proof wrapper for the database. The point is the make common use cases simple and allow the developer to incrementally use more SQL as needed, for more control.