[comp.windows.x] Xt program resource files - How much is enough?

dce@smsc.sony.com (David Elliott) (03/27/91)

Somehow, I got this (strange?) idea that when one writes an Xt-based
application, one is supposed to put as much of the resource information
as possible in a resource file.

As a result, I write applications where the only calls to XtSetValues
are done when the resources have to be determined at run-time.  This
includes putting all of the Form and other constraint/composite widget
resources in an app-defaults file.

I believe that this gives my "customers" extra advantages.  For
example, if someone needs to find out the widget hierarchy, my
app-defaults file tells them this, and even shows them which resources
are being used to lay things out.  Within reason, they can even change
the layout of the program.  It also has the advantage that my
applications can be changed to support other (human) languages very
easily.

So, am I going overboard, or are application programmers that don't go
that extra mile just being lazy?

nazgul@alphalpha.com (Kee Hinckley) (03/27/91)

In article <1991Mar27.020710.22641@smsc.sony.com> dce@smsc.sony.com (David Elliott) writes:
>I believe that this gives my "customers" extra advantages.  For
>example, if someone needs to find out the widget hierarchy, my
>app-defaults file tells them this, and even shows them which resources
>are being used to lay things out.  Within reason, they can even change
>the layout of the program.  It also has the advantage that my
>applications can be changed to support other (human) languages very
>easily.
>
>So, am I going overboard, or are application programmers that don't go
>that extra mile just being lazy?

Depends on what kind of customers you have.  The hackers will be
delighted.  A smart user might possibly figure things out assuming
that all the resources are well documented.  Anyone else may well
screw themselves up.  Also you are taking a certain amount of
performance hit for increasing the number of resources (particularly
in R4, where there are leaks if you delete widgets).  I don't think
that a resource file is any substitute for a good preferences facility
built into the program.  But I suspect that this quickly becomes a
religious argument.


-- 
Alfalfa Software, Inc.          |       Poste:  The EMail for Unix
nazgul@alfalfa.com              |       Send Anything... Anywhere
617/646-7703 (voice/fax)        |       info@alfalfa.com

I'm not sure which upsets me more: that people are so unwilling to accept
responsibility for their own actions, or that they are so eager to regulate
everyone else's.

colin@nbc1.ge.com (Colin Rafferty) (03/29/91)

In article <1991Mar27.020710.22641@smsc.sony.com> dce@smsc.sony.com (David Elliott) writes:

[ describes how he never uses XtSetValues() except for dynamic values ]

> I believe that this gives my "customers" extra advantages.  For
> example, if someone needs to find out the widget hierarchy, my
> app-defaults file tells them this, and even shows them which resources
> are being used to lay things out.  Within reason, they can even change
> the layout of the program.  It also has the advantage that my
> applications can be changed to support other (human) languages very
> easily.

> So, am I going overboard, or are application programmers that don't go
> that extra mile just being lazy?

This is exactly the correct thing to do.  I have to admit that I don't
do this, but I write applications that are usually of limited use, so
it's far easier for me to change the UIL file (yes, motif) for the one
person using it then to have her deal with defaults.

If you're distributing the program to many people, then this is
exactly what you should be doing (and given your organization, I
assume that you are distributing your software widely).

What it really comes down to is that if the user doesn't want to deal
with overriding anything, the program still works just as well.

I wish more people who distribute software would act the way that you
do.

In fact, I'm going to go through the program that I just finished and
change it all to use as much of an app-defaults file as possible.

-- 
Colin Owen Rafferty              |      I believe in compulsory cannibalism.
colin@nbc1.ge.com                |      If people were forced to eat 
(I don't speak for NBC.          |      what they killed, there would
Watch Tom Brokaw for that.)      |      be no more wars.      -- Abbie Hoffman

meo@Dixie.Com (Miles ONeal) (03/29/91)

Too much is almost enough.

Unless you give them a too-easy way to really break something,
it's difficult to give them too much flexibility. I build in
reasonable, minimum defaults via the Arg structs [1] and try
to leave the product as configurable as possible. You may
need to occasionally test something in the code to make sure
things work OK.

I have been in situations where everyone likely to use the
thing had to be considered an idiot who might also explore,
so I had to take precautions against them. So far, I haven't
needed to do much of that in X.

I like the MIPS approach, as explained in the Wcl-based debugger
talk at this year's XTC - give them the capability, give them
a supported configuration, document the capability, and let
them go.

If you are writing software for the DIA, etc, you may have to
do things like hardcode colors and such [2], but most of us don't
do a lot of work that falls into that category...

-Miles

[1] I prefer to declare & initialize them together, at compile
    time, instead of link time, but almost everything I see in
    books or across the net initializes via XtSetArg().

[2] They get really ill at the idea of someone setting FG & BG
    to the same color, say, on a titlebar. Can't really blame
    them.

dce@smsc.sony.com (David Elliott) (03/30/91)

In article <8887@rsiatl.Dixie.Com>, meo@Dixie.Com (Miles ONeal) writes:
|> Unless you give them a too-easy way to really break something,
|> it's difficult to give them too much flexibility. I build in
|> reasonable, minimum defaults via the Arg structs [1] and try
|> to leave the product as configurable as possible. You may
|> need to occasionally test something in the code to make sure
|> things work OK.

Wouldn't it be better to use the fallback resources string
instead of using Arg structs?  I'm assuming that for "reasonable,
minimum defaults" that you mean enough so that a missing app-defaults
file doesn't mess you up.

-- 
...David Elliott
...dce@smsc.sony.com | ...!{uunet,mips}!sonyusa!dce
...(408)944-4073
..."His lower lip waved poutily with defiance..."