Discussion:
Data hiding and type safety
(too old to reply)
Anton
2008-02-23 21:51:23 UTC
Permalink
Hi all,

I am just interested what is the Pascal way of dealing with
(type) safety and data hiding.

For example, I am writing a module that handles threaded
trees. What should it export?

If I export the definiton of my tree type, I'll disclose my
internals, which is not safe (no data hiding); on the other
hand, if I don't do it, the interface functions will have to
operate with an index or a pointer to indentify a tree inside
my module, which is not type safe...

Doesn't Extended Pascal deal with such problems by offering
restricted types?

Thanks in advance,
Anton
John Reagan
2008-02-25 21:06:38 UTC
Permalink
Post by Anton
Doesn't Extended Pascal deal with such problems by offering
restricted types?
Yes, EP added restricted types in lieu of an OO system with private
data. I'm not a big fan of the direction the committee took with those
features.
--
John Reagan
OpenVMS Pascal/Macro-32/COBOL Project Leader
Hewlett-Packard Company
Anton
2008-02-25 22:13:23 UTC
Permalink
Thanks for the reply, John!
Post by John Reagan
Yes, EP added restricted types in lieu of an OO system with private
data. I'm not a big fan of the direction the committee took with those
features.
But that's great: good data hiding without the OOP pains!

My main queston was: how do Standard Pascal programmers deal
with this? I mean, I might be missing a way of avoiding this
dilemma of either exporting types or function that work with
"pointers". And if it exists, then which of the alternaties is
usually chosen?

Anton
John Reagan
2008-02-26 16:20:58 UTC
Permalink
Post by Anton
My main queston was: how do Standard Pascal programmers deal
with this? I mean, I might be missing a way of avoiding this
dilemma of either exporting types or function that work with
"pointers". And if it exists, then which of the alternaties is
usually chosen?
Anton
In 7185 Pascal, there isn't a language feature to protect/abstract
a record's implementation. Just lots of documentation, honest
programmers, and code reviews.
--
John
Anton
2008-02-26 21:20:49 UTC
Permalink
Post by John Reagan
In 7185 Pascal, there isn't a language feature to protect/abstract
a record's implementation. Just lots of documentation, honest
programmers, and code reviews.
Honest progrmmers -- Great!
Code reviews -- Good!
Docs -- Hmmm, whad docs do you mean?
if it's the standard Pascal site, then
most of them are historical...

Anton
John Reagan
2008-02-27 19:16:09 UTC
Permalink
Post by Anton
Post by John Reagan
In 7185 Pascal, there isn't a language feature to protect/abstract
a record's implementation. Just lots of documentation, honest
programmers, and code reviews.
Honest progrmmers -- Great!
Code reviews -- Good!
Docs -- Hmmm, whad docs do you mean?
if it's the standard Pascal site, then
most of them are historical...
Anton
No, the docs you write to give to your honest programmers telling then
which fields in the record are "public", which are "private", and what
you'll do to them if they cheat. You might want to use some naming
convention as an aid.
--
John
Anton
2008-02-27 20:14:40 UTC
Permalink
Post by John Reagan
No, the docs you write to give to your honest programmers telling then
which fields in the record are "public", which are "private", and what
you'll do to them if they cheat. You might want to use some naming
convention as an aid.
Oh, and I suppose you mean peer reviews of code?
John Reagan
2008-02-27 20:53:08 UTC
Permalink
Post by Anton
Oh, and I suppose you mean peer reviews of code?
We do peer review for most complicated items. I don't bother for
trivial edits, but during certain critical periods (like just before
field test or release), we review everything just so we don't break the
nightly build and waste a day. I don't use any particular formal review
method, but there are several styles that might be helpful.

Personally, for complicated bugfixes or new features, I do test reviews
as well. In the past, I've made engineers write their tests (and have
them reviewed) before they write their code (plus more tests afterwards
if desired).
--
John
Loading...