Hi -- On Tue, 5 Aug 2008, Avdi Grimm wrote: > On Sun, Aug 3, 2008 at 2:23 PM, David A. Black <dblack / rubypal.com> wrote: >> I'm afraid I don't see the advantage of that, at least in every case, >> over bootstrapping at least part of a database schema and model >> structure first. Certainly the kind of thing you're describing does >> happen, but if I'm creating an Order model and I know that it's going >> to belong to Customer, I'm not averse to saying so up front. Also, >> with a large table, you could get into an awful lot of migrations. > > I've seen a lot of Rails coders completely lose track of the fact that > "Model" means "Domain Model" because of thinking like that. To the > point of getting confused when you start talking about models that > don't derive from ActiveRecord::Base. They've begun to identify > "Model" with "table in the database" rather than "model of a domain > entity". I repeat: *if* I'm creating an Order model and I know that it's going to belong to Customer, etc. That's not the only possible scenario, but it can happen. Obviously it has no bearing on non-AR models, and so forth. There's definitely an issue with over-identification of models and tables, but we've been talking rather specifically about the case where the associations and table structure are already known (or at least a piece of them), and whether or not it makes sense, in the presence of that knowledge, to refrain from implementing those things until there are failing tests for them. The question of whether to use belongs_to and so forth in the first place is important but different. > I challenge any Rails developer to start a a web app without a > database, leaving persistence for iteration 2. It can be an > eye-opening experience, forcing you to think more about domain > concerns and less about keeping MySQL happy. I usually do it sort of the other way around: model the domain first, then think about how that will play out in a database schema, and then start to think about it as a Web app. I often spend a lot of time in the console before I create a controller. Some people like to work view-first. I'm the opposite. I've never thought about keeping MySQL happy, I have to admit. I expect it to keep me happy :-) David -- Rails training from David A. Black and Ruby Power and Light: * Advancing With Rails August 18-21 Edison, NJ * Co-taught by D.A. Black and Erik Kastner See http://www.rubypal.com for details and updates!