This should be a simple question...

andrew cooke andrew at acooke.org
Fri Mar 6 10:13:35 EST 2009


Neal Becker wrote:
> What if I had:
>
> my_obj = common_variables()
> That set all these attributes, but then with function A I inject them into
> A's scope (shouldn't be too hard to do, I think)?

"DRY" is a shorthand for people to remember, but it's not a direct law.  i
am worried that you are trying to solve "DRY" rather than thinking about
why the the shorthand exists or what it means.

DRY exists because it is important to avoid repeating logic ("meaning") in
various parts of your program.  it is not important because there is some
kind of tax on keystrokes, or because your fingers are tired.

so "common_variables" is a flag something is wrong.  if they are just
random variables then you are wasting your time.  DRY is about when the
repeated things have a shared *meaning*.  and if they have a shared
meaning the class name should be something that *means* something more
than just "common variables".

please, try *thinking* about what the rules mean, instead if just
following them.

andrew





More information about the Python-list mailing list