|Do you know where your variables are?|
Re^4: multiple method calls against the same object (f.ex GUI programming)by Aristotle (Chancellor)
|on Oct 29, 2002 at 02:16 UTC||Need Help??|
Sorry, one steap ahead of you again. :-) That breaks down when you need to add a nameless widget to another also nameless widget:
You need a temporary variable, although at least this one can be tightly scoped.
It also mingles method calls against several different widgets into a single block, which makes it harder to see what gets added where when. Your proposal is ok on a smaller scale, but scales badly - if you nest several unnamed widgets, it gets messy quick.
If you look at the tutorial at GtkPerl.org you'll see a really ugly style with lots of variable reuse and calls to different widgets interwoven in a single block. It made my head swim trying to read even the shorter example programs. configure_object was the result of several iterations of refactoring for readability.
It took enough effort and was beneficial enough that I felt I had to share this.
Update: Actually I suppose one can coerce the for approach into clean separation by adding some do to the mix:
but that's quickly slipping into the realm of cumbersome. I really spent some serious time trying to get this whole deal to look reasonably readable, and no conventional tools would help, hence the snippet.
Makeshifts last the longest.