in reply to Loading Functionality From SubModules

As you've noticed, inheritance isn't really a good match for this kind of thing. It looks like it would be a better match for mixins, if Stat's methods are going to be reused in another class (like Directory).

Or you could achieve basically the same thing by having Directory and File inherit from FileSystemObject (i.e. Stat with a slightly more useful name)

Also, why are you requiring modules every time someone instantiates an Object?

update: fixed link

  • Comment on Re: Loading Functionality From SubModules

Replies are listed 'Best First'.
Re^2: Loading Functionality From SubModules
by Ace128 (Hermit) on Jan 13, 2007 at 20:05 UTC
    Also, why are you requiring modules every time someone instantiates an Object?
    Woops.. Well, that was just a copy 'n paste from something I found here doing with plugins...

    Update: And good idea with the FileSystemObject! Now, this I did here is just an example... That I use to test on. As noticed one can surely redo the hiarchy of the objects to a better one. But we can have this one for now... I can change that later when I have the solution I wanna use. (the mixin seems pretty nifty, but I'm gonna wait to see if others have other nice solutions). As it seems, maybe Stat wasn't a good example, as that should probably be a parent to File and Directory objects, but anyway.. still need a solution for other cases. And besides, its little easier to expand downward. Else one have to modify all mobules that are supposed to go below you... it could be a mess...