Re: GConf - defaults.



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.

I suspect this problem is familiar to anyone who has extensively used
gnome_config. Yes, you can get around this by:
 
 * Using #defines for your defaults
 * Providing wrapper functions to get each config value.

But that only works if the multiple places share common header files
or libraries, not always the case at all. And that also involves
*evil C API's* <shudder>.
  
Regards,
                                           Owen

 




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