[Nitro] og regarding legacy apps table hints
Aleksi Niemela
Aleksi.Niemela at cs.helsinki.fi
Tue Aug 16 15:32:15 EDT 2005
Robert Wagner wrote:
>hi,
>to be a bit more specific about the way to describe tables in an
>external file. how do you like that way:
>
>
>
I'm sorry but I don't understand at all what it is that we'd gain from
this representation? Why not simply use Ruby and Og and define the same?
>class Person
> look_at_file true
>end
>
>person.ini:
>
>; autogenerated file - generator: generator.php
>[table]
>name=persons
>sequence=persons_id_seq
>
>[keys]
>id=1
>
>[fields]
>; 1-number, 2-string, 3-date, 4-datetime, 5-blob
>id=1
>title=2
>fname=2
>lname=2
>address1=2
>address2=2
>country=2
>postalcode=2
>city=2
>phone=2
>fax=2
>mobile=2
>email=2
>web=2
>company_id=1
>creation=4
>lastedit=4
>version=1
>
>
>[autodate]
>created=creation
>modified=lastedit
>
>[autoinc]
>version=1
>
>[relations]
>has_many=notes
>belongs_to=company
>company.fkey=company_id
>notes.class=note
>
>
>
In this case all above might not be possible with Og, yet, but something
along lines:
class Person
property :title, :fname, :lname, :address1, :address2, :country,
:postalcode, :city, String
property :phone, :fax, :mobile, :email, :web, String
include Autodate
include AutoInc
autoinc :version
has_many Notes
belongs_to Company
end
There are or at least there will be ways to express foreign keys and
indexes, as well as map names of fields and tables etc. There will be
more useful parts (like autodate) for objects to be managed for
persistence to include when needed. What's that special usefulness that
your pure text version provides?
If you need this kind of definition to be somehow abstract, one should
be able to write a text to Og Ruby code translator pretty easily and
then one could convert the above text to above code for run-time
evaluation without great pains.
So again I making a question what's this all for? What do we gain by
adding an extra layer needing conversion?
What I can see that we're losing by using pure text (ini-file based or
not) data definition mini-language is the ability to use
turing-complete, working, easy, simple and useful full language to
describe a bit more complex issues. And do so even without having text
to code to datastructures conversion library source code, just by
extending where Og left.
Should you need to write to logfile every time object's accessor is
used, you're free to define your own "property" method for definition
language inside Ruby. Not to mention Og already supports Aspect Oriented
way to inject code.
- Aleksi
More information about the Nitro-general
mailing list