Elementary string-parsing

Steve Holden steve at holdenweb.com
Tue Feb 5 07:57:31 EST 2008


Marc 'BlackJack' Rintsch wrote:
> On Tue, 05 Feb 2008 06:19:12 +0000, Odysseus wrote:
> 
>> In article <60osssF1ro06iU5 at mid.uni-berlin.de>,
>>  Marc 'BlackJack' Rintsch <bj_666 at gmx.net> wrote:
>>
>>> Another issue is testing.  If you rely on global names it's harder to test
>>> individual functions. [...]
>>>
>>> In programs without such global names you see quite clearly in the
>>> ``def`` line what the function expects as input.
>> Good points, although thorough commenting can go a long way to help on 
>> both counts. In theory, at least ...
> 
> Won't work in practice so well.  Say we have function `f()` and
> document that it expects global name `a` to be set to something before
> calling it. `f()` is used by other functions so we have to document `a` in
> all other functions too.  If we change `f()` to rely on global name `b`
> too we have to hunt down every function that calls `f()` and add the
> documentation for `b` there too.  It's much work and error prone.  Easy to
> get inconsistent or missing documentation this way.
> 
Essentially what Marc is saying is that you want your functions to be as 
loosely coupled to their environment as practically possible. See

   http://en.wikipedia.org/wiki/Coupling_(computer_science)

[...]

regards
  Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC              http://www.holdenweb.com/




More information about the Python-list mailing list