Questions about app design - OOP with python classes
steve at REMOVE.THIS.cybersource.com.au
Sun Mar 4 00:15:31 CET 2007
On Thu, 01 Mar 2007 21:53:09 -0800, Paul Rubin wrote:
> Steven D'Aprano <steve at REMOVEME.cybersource.com.au> writes:
>> > 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.)
> Well, type systems in programming languages have generally proven more
> reliable and easier to deal with than having programmers track it all
> manually-- that's why we don't all write in Forth ;-).
Apps Hungarian is NOT a type system.
Systems Hungarian is. It is pointless: an inefficient, manual nuisance
that redundantly does what the type system already does. Even Microsoft
agrees with that now.
Unless there is a type system that can automatically deal with the
semantic difference between (say) screen coordinates and window
coordinates, or between height and width, or safe and unsafe strings, the
coder still has to deal with it themselves.
And even if there is such a type system, Python isn't it.
> You're right that this is not exactly dimensional analysis, but it still
> seems to call for types and conversion functions, rather than naming
The problem with types is that as far as the compiler is concerned, the
objects are the same type. Of course it needs conversion functions.
Now maybe you could argue that what Microsoft needed was a different
language instead of C. Maybe so, but they were working with what they
had. Just as we're working with Python.
The point I'm trying to get across isn't that Apps Hungarian is the best
imaginable solution to the problem of dealing with semantically different
kinds of data. But it is an easy solution that works quite well (not
perfectly) and (unlike relying on Haskell's type system) it can be
applied to Python quite easily.
More information about the Python-list