Hey Kristian,

Like the way you think!  Are you related to Tom? : -)

Want to move to DC? We could use you here. : -)

Owen

On Sep 19, 9:01 am, Kristian <[email protected]> wrote:
> I was thinking, why not allow for specifying domain models, contraints
> etc. externally in a canonical format that can be shared amongst
> different app frameworks/languages?
>
> Fx in JSON format:
>
> // control the execution of auto code refactoring
> execution : {
>         models: {
>                 on_exist: 'overwrite',
>                 user: {
>                         status: "done" // perform
>                 },
>                 project: {
>                         status: 'in progress', // don't change .rb model 
> class until
> status:done
>                         comment: {'expected done by dec. 1', author: 
> 'Kristian M', date:
> '1-9-2009'}
>                 }
>         },
>         // default status is 'done'
>         relations: {
>                 on_exist: 'comment',
>                 status: 'done'
>         },
>         named_types: {
>                 status: 'done'
>         }
>
> }
>
> // the domain model to use for auto-refactoring
> domain_model: {
>         models: {
>                 user: {
>                         // refers to named_types
>                         name: 'name',
>                         age: 'age'
>                         behavior: {
>                                 'simple_captcha'
>                         }
>                 },
>                 project: {
>                         name: 'name',
>                         description: 'description',
>                         behavior: {
>                                 acts_as: ['set', 'tree', 'countable']
>                         }
>                 },
>                 // join table: friend-friend
>                 friends_association: {
>                         status: 'friend_status',
>                         acts_as: ['countable']
>                 },
>                 // join table: member-project
>                 project_association: {
>                         status: 'project_membership_status',
>                         acts_as: ['countable']
>                 },
>                 album: {
>                         behavior: {
>                                 act_as: [{
>                                         'rateable',
>                                         options: {
>                                                 dimensions: ['fun', 
> 'quality']}
>                                         }
>                                 ]
>                         }
>                 }
>         },
>         relations: {
>                 // refers to models
>                 // relations can be either: 1-1, 1-M, M-M
>                 'user': {
>                         1-1
>                         belongs_to_one: ['parent': {
>                                         _class: 'user'
>                                         permissions: {
>                                                 roles: {
>                                                         create: ['admin'],
>                                                         update: ['>guest'],
>                                                         destroy: ['admin']
>                                                 }
>                                         },
>                                         comment: 'user belongs to one parent'
>                                 }
>                         ],
>                         // 1-M
>                         owns_many: ['items': {
>                                         dependent: 'destroy',
>                                         comment: 'user has many items, 
> ownership used by Hobo to set
> permission system rights!'
>                                 }
>                         ],
>                         // 1-M
>                         member_of_many : [
>                                 'projects'
>                                 through: 'project_association',
>                         ],
>                         // M-M
>                         knows_many: ['friends': {
>                                         _class: 'user',
>                                         through: 'friends_association',
>                                         comment: 'user has many friends'
>                                 },
>                         ],
>                 },
>                 // 1-M
>                 'project': {
>                         has_many : ['members': {
>                                 _class: 'user'
>                                 // no need to define through again!
>                         }]
>                 }
>         },
>         named_types: {
>                 name: {
>                         type:'string',
>                         constraints: {
>                                 'required'
>                         }
>                 },
>                 description: {
>                         type:'text',
>                         constraints: {
>                                 size: {min: 1, max: 2000},
>                                 'required'
>                         }
>                 },
>                 friend_status: {
>                         type: 'enum',
>                         ['pending', 'accepted']
>                 },
>                 project_membership_status: {
>                         type: 'enum',
>                         ['pending', 'accepted']
>                 },
>                 age: {
>                         type: 'integer',
>                         constraints: {
>                                 age: {range: {1, 65}, 'required'}
>                         }
>                 }
>         },
>         permissions: {
>                 roles: ['guest', 'project_admin', 'admin']
>         },
>         plugins: {
>
>         }
>
> }
>
> Then have a rake scriptor similar parse this model and update/refactor
> the hobo models/controllers accordingly.
> The idea here is, that other parsers/populators could be created for:
> "normal" Rails, Grails, Spring ROO, Java, ... etc. to update their
> respective models.
>
> This would allow a developer to design the model with the customer in
> a somewhat readable format (or have a skeleton generated from UML or
> similar) and then apply it on the code base.
>
> The idea is also to avoid the bloated format of something like UML,
> while allowing for much more freedom and flexibility. This model could
> easily be extended/customized You could even have an app that can
> display the model relationships graphically!
>
> Could this approach be useful or is it flawed in some fundamental way?
>
> Kristian
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to