Re: [Ongui-dev] Thoughts on programming idioms
Status: Alpha
Brought to you by:
robinrowe
|
From: Robin R. <ro...@Mo...> - 2003-12-30 01:26:06
|
Mike, > Well, so far my problem has been "I can't get any text to display." > Yesterday, I managed to get really really small text to display. If I > can't get this to work in a few more hours, I'll post my code to the > list. I sometimes have a hard time admitting defeat. It is exploration, not battle. Please describe what you encounter as you go along. Don't wait until after you finish the book to start telling the story! It's *interesting* why you can't get text to display. > It's interesting to me how different people think and approach reading > code. I prefer to know "What can I do with it", which is usually what > people walking up to an API will want to know. Me, too. Except, I want to know both what it *can* do and what it *could* do. If encapsulated nicely the data members tell that instantly. Then one can study the methods looking for the right one. It is annoying to search through a class looking for a method and discover later that the class doesn't even contain the requisite data. Not needing to know about the data is a theory promoted in a lot of books, but is contrary to human cognition or even common sense. How do people learn complex technology? Airplane pilots are taught how planes are built first so they understand what the controls do when they fly them. Having a pilot fly a plane by rote without understanding the mechanics is considered too dangerous. An example closer to home, try explaining the procedures for doing back-ups to someone who doesn't know about a disk drive. > Especially if data > members are private (they WILL be private, won't they?). Yes, but not for no reason. If a higher level class has embedded in it another encapsulated object whose data is already private then making it private a second time tends to be redundant and verbose. And, at the lowest level there is usually some raw data better off as unpretentious structs. A C-struct that has been made into a class with a zillion getter and setter methods is a nuisance. Data should be private where it protects the integrity of the data. > Actually, this was intentional. The C++ standard allows for "local" > classes, which is what I was intending to do here. This class is only > a one-off.... Let's not set out to prevent code from being reused! You never know. The local classes trick was an idea that at one time seemed a clever way to avoid name collisions, but we have namespaces now that are much simpler and better because they were designed specifically for that issue. Another thing with local classes, you can't count on all compilers supporting them (especially for your example within a function instead of a class) and even if they do compile the code can be sub-optimal. Local classes tend to stress compilers. It's not worth it. > Do you intend to pass commandline parameters to the OnGui > infrastructure? Yes, but only to pass it through to X11 as a legacy feature. I can't think of anything OnGui would want to do with command-line options. There are a couple ways to make the pass-through implicit so the user doesn't need to see it. No need to worry about it at this time. > I don't see this functionality in the gfx > archive (however, I'm not familiar with some of the Windows idioms > used there, so I may have missed it). That's because only X11 does that sort of thing. It isn't common elsewhere. > What's the advantage to having a member function MsgPump() for all top > level containers? Not having a Windows-centric background, this is a > little foreign to me. I think it is like gtk_main() or XtAppMainLoop(). > Also, I really dislike the use of the name of MsgPump(). It's too > hopelessly win32 to even bear. :) With your leave, I'd like to use > run() or another alternative name instead. Run() is fine by me, although not as descriptive. > One last question, regarding your allusion to a resource file in your > sample code. How much of the content do you see being managed by the > resource file? Possibly all object attributes? Should all objects take > an optional string name as a constructor parameter? My enthusiasm for resource files is limited. There's one feature they enable, but no GUI toolkit offers, that I want rather badly. I want to have a developer mode I can activate to do on-the-fly GUI-building inside a live app. In other words, it would be sort of like having Glade built into every OnGui app. I want to be able to prototype GUI design right inside any app, and not go through a compile cycle until I add functionality. > Again, thanks for your time and patience. You're welcome. And, thanks for your interest. You are supposed to ask questions! Cheers, Robin --------------------------------------------------------------------------- Rob...@Mo... Hollywood, California www.CinePaint.org Free motion picture and still image editing software |