4 ms·
I transcribed an interview with DHH [0] in which he also explains his motivations for choosing Ruby (instead of PHP or Java, for example), and where he explains
by Luyt 11y ago
I transcribed an interview with DHH [0] in which he also explains his motivations for choosing Ruby (instead of PHP or Java, for example), and where he explains some design principles for Rails.
[0] http://www.transcribed-interview.com/dhh-rails-david-heinemeier-hansson-interview-randal-schwartz-floss.html http://www.transcribed-interview.com/dhh-rails-david-heineme...
"One example I always pull out is “what you gonna call the primary key in your tables?” When I was working with PHP and Java, every single shop, almost every single application, would have its own naming scheme. Some would say they have the ‘Products’ table and then they'd have ‘productid’, others would have ‘product_id’, some people would have ‘prod_id’ or ‘p_id’ or ‘P_id’, and every time somebody made a new design decision it meant configuration. You now have to tell your models, your objects, how they're going to talk to this database table. Because it needs to know what the hell you called the freaking primary key column, and it just doesn't matter! Who cares what the primary key column is called? It just doesn't matter. It's going to have zero impact on the usefulness of your application."
and
"‘Dont repeat yourself’ is all about not having the same intentions spread out in multiple places. Don't have one configuration. If you're calling something, let's again take the example of the primary key. If you're calling that for ‘id’ you shouldn't have to configure that in three different places that all have to work together and all have to be changed together. You should just pick one authoritative place to have that information stored. And then you can make changes from there. It also goes with the the whole Ruby idiom: we don't want those Java boilerplate ten line things: that's repeating yourself. If you have the same idiom, if you have the same intentions, that should really be exceedingly a short expression. And that goes up throughout the entire framework. Just keep one place to change those things, and keep the idioms very short."
- edwinnathaniel 11y agoThat sounds like the pre-ORM days. These days ORM would map member variable id to database table id.
- Luyt 11y agoThe interview is from July 2009. I think Rails already had its ORM then. DHH says: "The model part in an MVC application is where all the business logic is kept. Those are all the classes like ‘Post’ and ‘Category’ and ‘Author’ and all those things –say if you're making a weblog– you'd keep all that stuff in the Model. And you'd have all the logic about whether the author is allowed to make a post and how the relationship between posts and comments work together. Those are all sitting in the model, so that's all the business logic, very often backed by a database in some sense, not always, but most of the time. And that's where in Rails we're using something called ‘ActiveRecord’. Which is this way of mapping database tables to objects, and then decorating those objects with logic."
- edwinnathaniel 11y agoI was referring to: > When I was working with PHP and Java, every single shop, almost every single application, ...
- hawleyal 11y agoI would say Rails is post-ORM. You don't even map anything. It's all convention. That is his point.
- edwinnathaniel 11y agoPlease refer to : https://news.ycombinator.com/item?id=10934605 https://news.ycombinator.com/item?id=10934605