Re: GConf - defaults.
- From: Owen Taylor <otaylor redhat com>
- To: Dietmar Maurer <dietmar ximian com>
- Cc: Havoc Pennington <hp redhat com>, Michael Meeks <michael ximian com>, Elliot Lee <sopwith redhat com>, gnome-hackers gnome org
- Subject: Re: GConf - defaults.
- Date: 21 Jun 2001 12:08:11 -0400
Dietmar Maurer <dietmar ximian com> writes:
> Owen Taylor wrote:
>
> > Dietmar Maurer <dietmar ximian com> writes:
> >
> > > Owen Taylor wrote:
> > >
> > > > Dietmar Maurer <dietmar ximian com> writes:
> > > >
> > > > Well, the problem with writing:
> > > >
> > > > GError *error = NULL;
> > > >
> > > > level = gconf_client_get_int (c, "user_level", &error);
> > > > if (error)
> > > > {
> > > > level = DEFAULT_LEVEL;
> > > > g_error_free (error);
> > > > }
> > > >
> > > > is not just the problem with writing this all over the place, but it
> > > > is also that these fall back defaults don't get used at all normally,
> > > > so they'll rot, and may not work at all.
> > >
> > > Why don't we simply use:
> > >
> > > level = bonobo_pbclient_get_int_with_default (db, "user_level", 0, NULL);
> >
> > To reiterate:
> >
> > * Hardcoding defaults into multiple places in the code is _evil_,
> > because they _will_ get out of sync.
>
> As you already mentioned, that default will only be used if everything else
> does not work. It is not the suggested method to hardcode defaults. It is
> totally pointless it that value is out of sync, since it will not be used
> normally. It is only a way to make the application more robust. Anyway, if
> gconf can really provide default values under all circumstances there is no
> problem at all.
Well, I can't claim that providing a value that isn't used makes things
work worse. But
Why should people have to provide it at all if it is never used at all?
*- If it ever does get used, it will quite likely be wrong, since it isn't
tested or kept in sync with the real defaults.
> Another reason for providing those functions is because it was already there
> in gnome_config_*, and it is also very useable to read PropertyBags associated
> with Controls.
I didn't suggest that you remove that function :-), though I would suggest
that people shouldn't be using it for config settings (when migrating from
gnome-config, you should be moving your defaults into scheme files).
And I would wonder - if you try to get a value from a propertybag that
doesn't have the property or has the wrong type for that property,
isn't that a bug in the program that should reported with g_warning(),
so it can be fixed?
Regards,
Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]