Why does python not have a mechanism for data hiding?

Bruno Desthuilliers bruno.42.desthuilliers at websiteburo.invalid
Wed Jun 11 04:10:14 EDT 2008


Russ P. a écrit :
> On Jun 10, 11:58 am, Jonathan Gardner
> 
(snip)
>> Who cares about private declarations, or interface declarations at
>> all? It is only a message to the developers. If you have a problem
>> with your users doing the right thing, that is a social problem, not a
>> technical one, and the solution is social, not technical. Yes, it is
>> work, but it is not coding---it is explaining to other living,
>> breathing human beings how to do a specific task, which is what you
>> should have been doing from the start.
> 
> You may be right to an extent for small or medium-sized non-critical
> projects, but you are certainly not right in general. I read something
> a while back about the flight software for the Boeing 777. I think it
> was something like 3,000,000 lines of Ada code.

I can't obviously back my claim, but you could probably have the same 
feature set implemented in 10 to 20 times less code in Python. Not that 
I suggest using Python here specifically, but just to remind you that 
kloc is not a very exact metric - it's relative to the design, the 
language and the programmer(s). The first project I worked on 
(professionaly) was about 100 000 locs when I took over it, and one year 
later it was about 50 000 locs, with way less bugs and way more 
features. FWIW, the bigger the project, the bigger the chances that you 
could cut it by half with a good refactoring.

> Normally, for a
> project of that magnitude  the final integration would be expected to
> take something like three months. However, the precise interface specs
> and encapsulation methods in Ada allowed the integration to be
> completed in just three days.
> 
> By your recommended method of social interaction, that would be one
> hell of a lot of talking!

Or just writing and reading.

> I realize that Python is not designed for such large projects,

Clueless again. Python is pretty good for large projects. Now the point 
is that it tends to make them way smaller than some other much more 
static languages. As an average, you can count on something between 5:1 
to 10:1 ratio between Java (typical and well-known reference) and Python 
for a same feature set. And the larger the project, the greater the ratio.

> but
> don't you think certain general principles can be learned anyway?

Do you really think you're talking to a bunch of clueless newbies ? You 
can bet there are quite a lot of talented *and experimented* programmers 
here.

> Perhaps the benefits of interface specs and encapsulation are not as
> obvious for smaller projects,

Plain wrong.

> but certainly they are not zero.

You still fail to get the point. Interface specifications and 
encapsulation are design principles. period. These principles are just 
as well expressed with documentation and naming conventions, and the 
cost is way lower.

Russ, do yourself a favor : get out of your cargo-cult one minute and 
ask yourself whether all python users are really such a bunch of 
clueless newbies and cowboy hackers. You may not have noticed, but there 
are some *very* talented and *experimented* programmers here.



More information about the Python-list mailing list