Web Frameworks Excessive Complexity

Andriy Kornatskyy andriy.kornatskyy at live.com
Wed Nov 21 12:09:38 CET 2012


We choose Python for its readability. This is essential principal of language and thousands around reading the open source code. Things like PEP8, CC, LoC are all to serve you one purpose: bring your attention, teach you make your code better.

Thanks.

Andriy


----------------------------------------
> From: ulrich.eckhardt at dominolaser.com
> Subject: Re: Web Frameworks Excessive Complexity
> Date: Wed, 21 Nov 2012 09:33:09 +0100
> To: python-list at python.org
>
> Am 21.11.2012 02:43, schrieb Steven D'Aprano:
> > On Tue, 20 Nov 2012 20:07:54 +0000, Robert Kern wrote:
> >> The source of bugs is not excessive complexity in a method, just
> >> excessive lines of code.
> >
> > Taken literally, that cannot possibly the case.
> >
> > def method(self, a, b, c):
> > do_this(a)
> > do_that(b)
> > do_something_else(c)
> >
> >
> > def method(self, a, b, c):
> > do_this(a); do_that(b); do_something_else(c)
> >
> >
> > It *simply isn't credible* that version 1 is statistically likely to have
> > twice as many bugs as version 2. Over-reliance on LOC is easily gamed,
> > especially in semicolon languages.
>
> "Don't indent deeper than 4 levels!" "OK, not indenting at all, $LANG
> doesn't need it anyway." Sorry, but if code isn't even structured
> halfway reasonably it is unmaintainable, regardless of what CC or LOC say.
>
>
> > Besides, I think you have the cause and effect backwards. I would rather
> > say:
> >
> > The source of bugs is not lines of code in a method, but excessive
> > complexity. It merely happens that counting complexity is hard, counting
> > lines of code is easy, and the two are strongly correlated, so why count
> > complexity when you can just count lines of code?
>
> I agree here, and I'd go even further: Measuring complexity is not just
> hard, it requires a metric that you need to agree on first. With LOC you
> only need to agree on not semicolon-chaining lines and how to treat
> comments and empty lines. With CC, you effectively agree that an if
> statement has complexity of one (or 2?) while a switch statement has a
> complexity according to its number of cases, while it is way easier to
> read and comprehend than a similar number produced by if statement.
> Also, CC doesn't even consider new-fashioned stuff like exceptions that
> introduce yet another control flow path.
>
>
> >> LoC is much simpler, easier to understand, and
> >> easier to correct than CC.
> >
> > Well, sure, but do you really think Perl one-liners are the paragon of
> > bug-free code we ought to be aiming for? *wink*
>
> Hehehe... ;)
>
> Uli
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
 		 	   		  


More information about the Python-list mailing list