Questions about app design - OOP with python classes

Steven D'Aprano steve at REMOVEME.cybersource.com.au
Thu Mar 1 23:47:38 EST 2007


On Thu, 01 Mar 2007 20:24:33 -0800, Paul Rubin wrote:

> Steven D'Aprano <steve at REMOVEME.cybersource.com.au> writes:
>> But if you used Apps Hungarian, and saw this line of code:
>> 
>> if hmmCurrentHeight <= hinCriticalHeight:
>> 
>> then you should instantly recognise that there's a problem. Comparing
>> a height in millimetres to a height in inches is not a good thing to do,
>> no matter that they're both floats.
> 
> That still sounds like an unreliable manual type system, 

It's unreliable in the sense that the coder has to follow the naming
convention, and must have some bare minimum of sense. If your coders are
morons, no naming convention will save you. (For that matter, nothing will
save you.)


> instead of an
> automatic type system that includes dimension analysis.  You might
> like this:
> 
>     http://futureboy.homeip.net/frinkdocs/
> 
> There are many Python implementations of dimensioned units as well.  I
> posted one here a few weeks ago.

Sure, and I love the Unix utility "units", and my HP calculator.
Dimensioned units are useful.

But dimensioned units are still only part of the story. Joel describes the
situation the early Word developers found: when you're writing a word
processor, you are doing a LOT of conversions between screen coordinates
and window pane coordinates. Both have the same type (a pair of ints),
both have the same dimensional units (length/pixels) but they are
semantically different. If you place the character "N" at coordinates 0,0,
it makes a big difference if the coordinates are relative to the current
window or relative to the screen.

Apps Hungarian is a heuristic for dealing with semantic differences, not
data types. It deals with more than just dimensional analysis.



-- 
Steven D'Aprano 




More information about the Python-list mailing list