Design principles: no bool arguments

Stefan Behnel stefan_ml at behnel.de
Thu Aug 25 13:01:22 EDT 2011


Thomas 'PointedEars' Lahn, 25.08.2011 11:29:
> Stefan Behnel wrote:
>> It's totally unreadable to find this in the code:
>>
>>       data1.merge_with(data2, true);
>>
>> Requires you to either a) know the underlying signature by heart, or b)
>> look it up before understanding the code.
>>
>> It's a lot harder to argue against this:
>>
>>       data1.merge_with(data2, overwrite_duplicates=True)
>[...]
> And you will still have to know the underlying signature to name the
> argument.  Worse, with keyword arguments you *have to* look up the
> documentation (i. e., it needs to be well-documented as well) to know its
> name (as the compiler can only tell you "kwargs").

Note that code is read more often than it gets written.

Stefan




More information about the Python-list mailing list