[Yum] Future feature request...

Michael Stenner mstenner at phy.duke.edu
Wed Nov 12 12:51:07 UTC 2003


On Tue, Nov 11, 2003 at 04:11:12PM -0500, seth vidal wrote:
> I think the idea is fine but this, like a lot of other things need to be
> added outside of yum, not in the core program. Otherwise the yum command
> ends up being yum [command] packages
> 
> where command is one of 80 different options.
> 
> I don't think that is good design and can you imagine that if statement?
> ;)

I know you were just joking (the smiley gave it away) but there is a
tidy solution to the "endless if" problem.

Make a dict[] of names->functions.  This makes the whole thing rather
modular and tidy.  Define the functions wherever you want, including
'plugins' if you like.  In one place, you stick them all into the
dict, and then you just do:

  try:
      command_dict[command_name](command_args)
  except KeyError:
      print "no such command"

I'm not arguing for rgb's suggestion.  I'm just pointing out that this
is often a nice way to deal with really long ifs :)

					-Michael
-- 
  Michael Stenner                       Office Phone: 919-660-2513
  Duke University, Dept. of Physics       mstenner at phy.duke.edu
  Box 90305, Durham N.C. 27708-0305



More information about the Yum mailing list