desperately in need of a tool

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Mon Aug 20 13:51:00 EDT 2007


yagyala a écrit :
> Hi.
> 
> I recently started working for a company that has just implemented its
> first set of software standards. So far, so good. Here's the problem:
> one of those standards is that the comments for each routine must
> indicate every other routine that it calls.

May I suggest that this is a totally *stupid* (and FWIW, totally 
impossible to apply) "standard" ?

Consider the following code, which is  totally dumb but quite close to 
real-life code in it's design (use of polymorphic dispatch, HOFs and 
anonymous functions...) :

def some_func(obj, callback):
   return callback(obj.method())

class One(object):
   def method(self):
     return 42

class Two(object):
   def __init__(self, val):
     self.val = val
   def method(self):
     return self.val / 3


def cb_one(val):
   return val + 2

def cb_two(val):
   return val * 3 + 42


arg_pairs = [(One(), cb_one),
              (One(), cb_two),
              (Two(33), cb_one),
              (Two(99), cb_two)
              (One(), lambda x: x ** 2]

for obj, cb in arg_pairs:
   print some_func(obj, cb)

How are you going to list the functions called by some_func ???

(snip)

> I'm sure some will wonder about the reasoning of this standard.

Indeed !-)

> The
> company primarily has experience writing scientific alogorythms which
> can get rather long. It makes a bit more sense to document all
> routines called for a very long routine, but for short routines that
> primarily call other routines, as most mine do, well....

Show the above code to your PHB and ask him to explain how you're going 
to apply the "standard"...




More information about the Python-list mailing list