Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.014 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; '21,': 0.07; 'happen,': 0.07; 'python': 0.09; 'counting': 0.09; 'metrics': 0.09; 'def': 0.10; 'read.': 0.13; 'language': 0.14; 'essential': 0.15; 'attention,': 0.16; 'contrived': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'perfect.': 0.16; 'pushes': 0.16; 'readability.': 0.16; 'wed,': 0.16; 'wrote:': 0.17; 'code.': 0.20; 'received:209.85.214.174': 0.21; 'regardless': 0.21; 'statement': 0.23; 'this:': 0.23; 'header:In-Reply-To:1': 0.25; 'message-id:@mail.gmail.com': 0.27; 'lines': 0.28; 'source': 0.29; 'code': 0.31; 'material': 0.33; 'to:addr:python-list': 0.33; 'agree': 0.34; 'received:google.com': 0.34; 'wrong': 0.34; 'list': 0.35; 'nov': 0.35; 'principal': 0.35; 'open': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'serve': 0.36; 'but': 0.36; 'too': 0.36; 'bad': 0.37; 'rather': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'easier': 0.38; 'things': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'short': 0.39; 'header:Received:5': 0.40; 'end': 0.40; 'your': 0.60; 'you.': 0.61; 'bring': 0.62; "you'll": 0.62; 'choose': 0.65; 'results': 0.65; 'of:': 0.65; 'teach': 0.69; 'benefit': 0.70; 'score': 0.75; 'complexity': 0.84; 'dense': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=73ctV56vTSCSWpWyJx/86Y19ItEd7agpiJdb6aIAJdY=; b=0baKXC3pR0mHFfOoDBnt2tCz97zSBhomib9AaqCeo+5/iBhO7HnOLXyp8lSrRwae7q a+aYaA5pF7wjywrQEsMFAJZeYOW09uBrrOHt2o+cQqhFrWnJ4+STAN1HLIyYrBNmXOFD j8SKIaz/d2bI66IO8qd2D8M/BZgQBEts1t9o/Fo4XcBjGT5Seh+f/XE78lWD32e++cXD u8cvsc1mNSuRZTLzY7ILlj66nwj7OJ1jCkS1o8hiZO69iOWdpbhGcXr+zKyULcXBeysv 6MwK8sc+Ccx3QgRWCGQQ9XWa49BYNJc9eO0ydXkhsga8dl4LlopFnVfgY+o0AXu73Js8 FNXg== MIME-Version: 1.0 In-Reply-To: References: <50ac31dd$0$29987$c3e8da3$5496439d@news.astraweb.com> <67gun9-kk8.ln1@satorlaser.homedns.org> Date: Wed, 21 Nov 2012 22:21:23 +1100 Subject: Re: Web Frameworks Excessive Complexity From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 35 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1353496885 news.xs4all.nl 6973 [2001:888:2000:d::a6]:58698 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:33716 On Wed, Nov 21, 2012 at 10:09 PM, Andriy Kornatskyy 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