RoR, Judge Judy, and little old ladies

Bruno Medeiros brunodomedeiros+spam at com.gmail
Wed Feb 21 09:59:49 PST 2007


Don Clugston wrote:
> Andrei Alexandrescu (See Website For Email) wrote:
>> Bruno Medeiros wrote:
>>> Sean Kelly wrote:
>>>> Bruno Medeiros wrote:
>>>>> Sean Kelly wrote:
>>>>>> Bruno Medeiros wrote:
>>>>>>> Robby wrote:
>>>>>>>> Bruno Medeiros wrote:
>>>>>>>>> In both cases, Ruby code is generated from
>>>>>>>>> code in these two DSLs, but that code generation is performed 
>>>>>>>>> not by the Ruby compiler during compile-time, but by an 
>>>>>>>>> external tool (similar to parser generators for example).
>>>>>>>> No, it's done with Ruby during run time, using Ruby's dynamic 
>>>>>>>> and reflective abilities.
>>>>>>>
>>>>>>> Hum, I had understood scaffolding to be the process where it 
>>>>>>> generated Ruby code by looking at the DB schema. So if I change 
>>>>>>> the DB schema, I don't have to run scaffolding again? I only need 
>>>>>>> to restart the web app, since it can reflectively and dynamically 
>>>>>>> create its own ORM logic?
>>>>>>
>>>>>> Unless you actually want to do something with that data, I assume.
>>>>>
>>>>> What do you mean? I am of course talking in the case where the web 
>>>>> app works with the data, otherwise the point of needing or not 
>>>>> needing to restart the app was moot.
>>>>
>>>> So say you modify your schema and the application self-adapts.  
>>>> Unless it is designed to merely pass all data through to the user 
>>>> (which may be common in web apps), the app will require some 
>>>> specialized code to operate on the data to achieve the desired 
>>>> result.  This obviously cannot be generated automatically because 
>>>> only the programmer knows what it should be.
>>>>
>>>>
>>>> Sean
>>>
>>> I suspect we're not understanding each other well. Of course business 
>>> logic is something that only the programmer knows, and the app cannot 
>>> generate that, but I'm not talking about actual business logic,  just 
>>> simple domain object creating, deletion, editing (and respective ORM 
>>> logic). Consider this pic from the article:
>>> http://www.onlamp.com/onlamp/2006/12/14/graphics/figure011.gif
>>> where the web app allows to create a domain object (recipe). That 
>>> functionality is automatically generated from the SQL tables, it is 
>>> achieved without any code written (except for SQL table creation).
>>> My question was whether this functionality was generated at "pre-run" 
>>> time (the scaffolding external tool), or at runtime (by the Ruby 
>>> webapp and it's dynamic capabilities).
>>
>> Yah, I have the same question. My current understanding is that 
>> generation is done statically (e.g. you must run the xyz program after 
>> you update your database structure...), which makes D's capability of 
>> doing that during compilation very attractive.
>>
>> Andrei
> 
> I don't think it is static, based on this quote:
> 
> When Active Record first uses a particular model, it goes to the 
> database and determines the column set of the corresponding table. From 
> there it constructs a set of Column objects. These objects are 
> accessible using the columns( ) class method, and the Column object for 
> a named column can be retrieved using the columns_hash( ) method. The 
> Column objects encode the database column’s name, type, and default value.
>  -- Agile Development with Rails, section 15.6.
> 

I asked a friend of mine who knows more about Ruby than me, and he said 
that Rails can actually do that generation in both occasions (runtime 
and "pre-run" time). If that's the case it surely would explain the 
confusion. :)

-- 
Bruno Medeiros - MSc in CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D



More information about the Digitalmars-d mailing list