Re: Help with retreiving children?



    -> In my personal view, those set and get functions lead to code bloat
    -> that I don't need.  I'll admit to not having actually tested my
    -> opinion, but I'm not getting paid to do this and I'm happy with my
    -> coding style.

    Derek> You could always access the struct components directly without
    Derek> writing the get/set fxns.  But since that would boil down to a GTK+
    Derek> function call on a "private" member of your struct, I think the
    Derek> code would be much clearer if you wrote a get/set.  Plus, when you
    Derek> change that textentry widget to a combo box, you only need to touch
    Derek> the code in one place, not every place you grab the value (aka
    Derek> "encapsulation").

The X Toolkit model of XtSetValues()/XtGetValues(), two functions that do all
the parameter getting and setting for all the objects, is a nice, clean,
simple approach, IMHO.  Keeps you away from accessing internals directly, and
avoids implementing large numbers of get/set functions.

Luckily, GTK+ already has the equivalent, and I pretty much use them instead
of separate get/set functions: gtk_widget_set(), gtk_widget_setv(),
gtk_widget_get, and gtk_widget_getv().
-----------------------------------------------------------------------------
Mark Leisher
Computing Research Lab            Once you fully apprehend the vacuity of a
New Mexico State University       life without struggle, you are equipped
Box 30001, Dept. 3CRL             with the basic means of salvation.
Las Cruces, NM  88003                            -- Tennessee Williams





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]