Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #33716
| References | (2 earlier) <DUB117-W66187DFCFCCDBA9E2710E091550@phx.gbl> <mailman.85.1353442093.29569.python-list@python.org> <50ac31dd$0$29987$c3e8da3$5496439d@news.astraweb.com> <67gun9-kk8.ln1@satorlaser.homedns.org> <DUB117-W33D7E1124EE9D7B659E50991540@phx.gbl> |
|---|---|
| Date | 2012-11-21 22:21 +1100 |
| Subject | Re: Web Frameworks Excessive Complexity |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.140.1353496885.29569.python-list@python.org> (permalink) |
On Wed, Nov 21, 2012 at 10:09 PM, Andriy Kornatskyy
<andriy.kornatskyy@live.com> wrote:
> 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.
But too much focus on metrics results in those metrics improving
without any material benefit to the code. If there's a number that you
can watch going up or down, nobody's going to want to be the one that
pushes that number the wrong direction. So what happens when the right
thing to do happens to conflict with the given metric? And yes, it
WILL happen, guaranteed. No metric is perfect.
Counting lines of code teaches you to make dense code. That's not a
good thing nor a bad thing; you'll end up with list comprehensions
rather than short loops, regardless of which is easier to actually
read.
Counting complexity by giving a score to every statement encourages
code like this:
def bletch(x,y):
return x + {"foo":y*2,"bar":x*3+y,"quux":math.sin(y)}.get(mode,0)
instead of:
def bletch(x,y):
if mode=="foo": return x+y*2
if mode=="bar": return x*4+y
if mode=="quux": return x+math.sin(y)
return x
Okay, this is a stupid contrived example, but tell me which of those
you'd rather work with, and then tell me a plausible metric that would
agree with you.
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Web Frameworks Excessive Complexity Robert Kern <robert.kern@gmail.com> - 2012-11-20 20:07 +0000
Re: Web Frameworks Excessive Complexity Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-21 01:43 +0000
Re: Web Frameworks Excessive Complexity Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-11-21 09:33 +0100
RE: Web Frameworks Excessive Complexity Andriy Kornatskyy <andriy.kornatskyy@live.com> - 2012-11-21 14:09 +0300
Re: Web Frameworks Excessive Complexity Chris Angelico <rosuav@gmail.com> - 2012-11-21 22:21 +1100
Re: Web Frameworks Excessive Complexity Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-21 11:43 +0000
RE: Web Frameworks Excessive Complexity Andriy Kornatskyy <andriy.kornatskyy@live.com> - 2012-11-21 14:47 +0300
Re: Web Frameworks Excessive Complexity Chris Angelico <rosuav@gmail.com> - 2012-11-22 09:12 +1100
Re: Web Frameworks Excessive Complexity Modulok <modulok@gmail.com> - 2012-11-21 22:22 -0700
RE: Web Frameworks Excessive Complexity Andriy Kornatskyy <andriy.kornatskyy@live.com> - 2012-11-21 14:45 +0300
Re: Web Frameworks Excessive Complexity Robert Kern <robert.kern@gmail.com> - 2012-11-21 11:47 +0000
csiph-web