On Tue, 16 Mar 2010 00:04:59 +0900, Andrea Dallera wrote:

> Hi everybody,
> 
> 	the whole issues comes from here:
> http://github.com/bolthar/freightrain/blob/master/lib/freightrain/
freight_view_model.rb
> FreightViewModel is part of the framework, and if you're using it that's
> the way you should do it:
> 
> class MyViewModel < FreightViewModel
> 
> ...
> 
> end
> 
> what i don't like is that if you want to make _your_ viewmodel do stuff
> on initialize, which is usual, you have to write your initialize method
> as such:
> 
> def initialize
>   super
>   #your stuff here
> end
> 
> otherwise the automagical initialization (like building views, hooking
> to services, etc) doesn't work, because the constructor of
> FreightViewModel (that is the one taking care of all this) doesn't get
> called.
> I know this is not extremely important (you just have to remind to call
> super) but i'd prefer not to have that hassle : i forget it myself more
> than often.

You ought to just get in the habit of remembering it.

Maybe you can write some kind of automatic checker that will look for 
definitions of initialize that don't call super.

I think it's always appropriate to call super in an initialize call, 
because everything descends from Object, and Object defines an initialize 
method.

--Ken

-- 
Chanoch (Ken) Bloom. PhD candidate. Linguistic Cognition Laboratory.
Department of Computer Science. Illinois Institute of Technology.
http://www.iit.edu/~kbloom1/