Re: WOComponents, Packages, and Protected variables.

From: Mike Schrag (mschra..dimension.com)
Date: Thu Aug 16 2007 - 12:55:39 EDT

  • Next message: Guido Neitzer: "Re: WOComponents, Packages, and Protected variables."

    I'm with Guido insofar as he says "it's not good practice" (and _not_
    with him on the part where he does it anyway ;) ). Type is good.
    The validator just turns off when you bind values into and out of an
    NSMutableDictionary. You are going to have to bind to that object
    all over the place -- in the item ref, in anything inside the
    repetition that uses it, in any action methods that act upon it. So
    you're either going to be casting in your Java code for action
    methods, or you're going to just give up type checking in your WOD.
    Even if you just make a public field, it's better than dumping into a
    dictionary. The validator can then check your references, completion
    works for you, the compiler can type check in your action methods,
    you can refactor (though WOD doesn't support refactoring yet, it will
    one of these days).

    While I agree that less code is usually a good thing, I would go for
    "say as little as possible without saying too little", and while I
    know Chuck may hate me for it, type is good.

    ms

    On Aug 16, 2007, at 11:58 AM, Guido Neitzer wrote:

    > On 16.08.2007, at 08:59, David Avendasora wrote:
    >
    >> This idea intrigues me. Can you explain further? Would this be a
    >> good "Best Practice" to follow?
    >
    > No, it's probably not good practice as other developers might see
    > your component and aks "What the he...?".
    >
    > It is because I'm lazy, I don't want to have tons of simple things
    > lying around in my classes (the less code the better) and that's it.
    >
    > For the usage:
    >
    > I have an NSMutableDictionary called "dynamicBindings" on the
    > superclass of all my components. I use it mostly for the "item"
    > binding in repetitions, but also, when I calculate strings or other
    > values somewhere and only use them to display them somewhere in the
    > HTML. There are tons of different usage scenarios, if your
    > comfortable with Key-Value-Coding, you'll get used to some of them
    > and will use them. Or not. Or whatever.
    >
    > cug



    This archive was generated by hypermail 2.0.0 : Thu Aug 16 2007 - 12:56:53 EDT