Web Frameworks Excessive Complexity

Chris Angelico rosuav at gmail.com
Wed Nov 21 17:12:53 EST 2012


On Wed, Nov 21, 2012 at 10:43 PM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> On Wed, 21 Nov 2012 22:21:23 +1100, Chris Angelico wrote:
>
>> 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
>
>
> Am I being paid by the hour or the line?

You're on a salary, but management specified some kind of code metrics
as a means of recognizing which of their programmers are more
productive, and thus who gets promoted.

Oh, I'm *so* glad I work in a small company. We've only had one
programmer that we "let go" (and actually, it was literally letting
him go - he said he was no good, hoping that we'd beg him to stay, and
we simply didn't beg him to stay), and the metric of code quality was
simply that both my boss and I looked at his code and said that it
wasn't good enough. Much simpler. (Though my boss and I have differing
views on how many lines of code some things should be. We end up
having some rather amusing debates about trivial things like line
breaks.)

ChrisA



More information about the Python-list mailing list