Code smells: too many parameters, too many attributes (was: pylint -- should I just ignore it sometimes?)

Ben Finney ben+python at benfinney.id.au
Wed Oct 20 03:09:35 CEST 2010


Seebs <usenet-nospam at seebs.net> writes:

> I'm pretty much mystified by a claim that something with seven
> instance attributes is "too complicated".

It's a code smell. Many discrete attributes is a sign that the design
can be improved by combining related attributes into a complex type.

It's pretty much the same smell, with the same range of solutions, as
too many parameters for a function.

    <URL:http://www.c2.com/cgi/wiki?TooManyParameters>
    <URL:http://www.refactoring.com/catalog/introduceParameterObject.html>

-- 
 \         “Science is a way of trying not to fool yourself. The first |
  `\     principle is that you must not fool yourself, and you are the |
_o__)               easiest person to fool.” —Richard P. Feynman, 1964 |
Ben Finney



More information about the Python-list mailing list