Web Frameworks Excessive Complexity

Modulok modulok at gmail.com
Thu Nov 22 06:22:54 CET 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
>>
>>

> Oh, I'm *so* glad I work in a small company.

Agreed. Do we rate a contractor's quality of workmanship and efficiency by the
number of nails he drives?

Of course not. That would be ridiculous.

A better metric of code quality and complexity would be to borrow from science
and mathematics. i.e. a peer review or audit by others working on the project
or in the same field of study. Unfortunately this isn't cheap or easily
computed and doesn't translate nicely to a bar graph.

Such is reality.
-Modulok-


More information about the Python-list mailing list