Re: WOComponents, Packages, and Protected variables.

From: Chuck Hill (chil..lobal-village.net)
Date: Thu Aug 16 2007 - 13:05:32 EDT

  • Next message: Chuck Hill: "Re: WOComponents, Packages, and Protected variables."

    On Aug 16, 2007, at 9:55 AM, Mike Schrag wrote:

    > 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.

    Better sit down. I agree with you. :-) Though not so much for
    "type is good" but "API is good". Having all this in a dictionary
    hides the API. The binding validation is a valuable side effect ;-)
    and this _is_ Java so you might as well benefit from the type system.

    Chuck

    > 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
    >
    >
    >

    -- 
    

    Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems. http://www.global-village.net/products/practical_webobjects



    This archive was generated by hypermail 2.0.0 : Thu Aug 16 2007 - 13:06:51 EDT