
Models vs. Modules - brm
http://www.37signals.com/svn/posts/1553-models-vs-modules
======
raganwald
Reminds me of... _Favour object composition over class inheritance_ , only we
are talking about mixin inheritance instead of class inheritance.

------
zepolen
Summary: Object oriented beats monkey patching.

~~~
jamis
Actually, the two are orthogonal. You can monkey-patch an aggregation into a
model as easily as you can monkey-patch anything else in.

Also, modules aren't monkey-patching. :)

    
    
      http://en.wikipedia.org/wiki/Monkey_patch
    

Lastly, the modules referred to in the article were added statically, not
dynamically. We don't use a lot of dynamic module inclusion (though we do it
some).

------
diN0bot
in django i separate model components into different files and then mixin in
the relevant fields and methods. for example, suppose i define models Blog and
Post in blog.py, and Rating and RatingMixin (extends object not base model).
I'd give Rating a method, say Initialize, that gets called when importing the
whole models folder. Rating.Initialize() would then mixin all the fields and
methods in RatingMixin to the specified models. In this case, it might be
useful to give Blog and Post the method "average_method".

Is this good practice?

Also, what's the advantage of keep lots of data in a single row versus
multiple tables? Does it effect performance that much (esp with caching)?

------
namcos
Simple question, why not have a db backed Avatar model instead?

~~~
jamis
It is db-backed. It's just that the fields exist on the people table, instead
of in their own table.

~~~
namcos
Thanks, I never noticed model aggregation before. Looks really useful.

