[comp.lang.c] A bad design decision early on in A

mcdonald@uxe.cso.uiuc.edu (01/02/88)

>	But they do - they add data hiding.  A library can provide
>	types such as time_t and addr_t for data that is generated by
>	some library routines and used by others, and *you* don't have
>	to know what the type is.  If the variable won't fit in a
>	scalar on your machine (either because it's too big, or because
>	you've got a segmented architecture or perverse operating system),
>	and you've disallowed structure assignment, *you* may have to
>	know what the structure looks like inside.

Data hiding is the worst idea ever invented. I really hate it when I find
something declared as a "time_t", or , worse, those awful structures
used by VMS C for system calls. Then one has to go back through some long
chain of garbage to find what they really mean. Luckily, this sort of
stuff is not rampant in the C community; if you want to experience it
in its full hideousness, write a program for the Macintosh; the notorious
system manuals are written in (ugh!) Pascal, with EVERYTHING a different,
useless, type. Horrible.

time_t itself is a rather ok idea, and I think one should be able to pass
structures. What I object to is the actual "hiding" of the definition
(in the sense of making it hard to find - it's usually in some 50 kilobyte
header file that bogs down the compilation of every program that uses it.)

Doug McDonald

ugfailau@sunybcs.uucp (Fai Lau) (01/04/88)

In article <47000028@uxe.cso.uiuc.edu> mcdonald@uxe.cso.uiuc.edu writes:
>
>Data hiding is the worst idea ever invented. I really hate it when I find
>something declared as a "time_t", or , worse, those awful structures
  ........
>
>time_t itself is a rather ok idea, and I think one should be able to pass
>structures. What I object to is the actual "hiding" of the definition
>(in the sense of making it hard to find - it's usually in some 50 kilobyte
>header file that bogs down the compilation of every program that uses it.)
>
	I'll have to agree. If you have really settled in doing your
works in C, then you can't be too concerned about using things
like data hiding for its own sake. C is such a unstructured language
that the best way to use it is to use it in any which way it works.
C structure passing isn't the worse that can be. Module-2 is so
must worse.

Fai  Lau
SUNY at Buffalo (The Arctic Wonderland)
UU: ..{rutgers,ames}!sunybcs!ugfailau
BI: ugfailau@sunybcs INT: ugfailau@cs.buffalo.EDU

rgr@m10ux.UUCP (Duke Robillard) (01/05/88)

In article <47000028@uxe.cso.uiuc.edu> mcdonald@uxe.cso.uiuc.edu writes:
>>	But they do - they add data hiding.  A library can provide
>>	types such as time_t and addr_t for data that is generated by
>>	some library routines and used by others, and *you* don't have
>>	to know what the type is.  If the variable won't fit in a
>Data hiding is the worst idea ever invented. I really hate it when I find
>something declared as a "time_t", or , worse, those awful structures
>used by VMS C for system calls. Then one has to go back through some long
>chain of garbage to find what they really mean. 

This is because you're not really hiding the data.  You still have to 
know what time_t is to use the information.  I hate this too.  Pascal's
types can lead to a viciously unreadable program by their misuse.

But with a *real* implementation of data hiding, you wouldn't have to
go back through that long chain of garbage.  To set some variable of
type foo, you'd call a function called set_foo.  To print the time,
you'd call a routine called print_time_t.  This is a major concept 
behind "object oriented programming" languages, like smalltalk or (maybe)
C++.



-- 
+                                
|               Duke Robillard, novice pagan. 
|       AT&T Bell Labs           m10ux!rgr@ihnp4.UUCP                 
|       Murray Hill, NJ          {any biggy}!ihnp4!m10ux!rgr

oleg@quad1.quad.com (Oleg Kiselev) (01/06/88)

In article <7611@sunybcs.UUCP> ugfailau@joey.UUCP (Fai Lau) writes:
>	I'll have to agree. If you have really settled in doing your
>works in C, then you can't be too concerned about using things
>like data hiding for its own sake. C is such a unstructured language
>that the best way to use it is to use it in any which way it works.

That's absolute rubbish.  "Data hiding" is a handy and elegant concept that
relieves programmers from being forced to write hard-to-modify code.  That's
why libraries are such a convenient way to deal with large data constructs:
the internal (in library) representation and handling of data can be changed
at any time without having to change any of the code using the library 
(assuming the code is well-behaved and is not snooping in the innards of the
data structs).  

C is a very good language to implement the "orthodox" software engineering
concepts.  It can be made very structured and very easy to read and modify
(as well as it can be perverted into an obfuscated, unreadable and 
unmodifiable monstrosity).
-- 
Oleg Kiselev  --  oleg@quad1.quad.com -- {...!psivax|seismo!gould}!quad1!oleg
HASA, "A" Division

DISCLAIMER:  I don't speak for my employers.

nevin1@ihlpf.ATT.COM (00704A-Liber) (01/09/88)

In article <472@m10ux.UUCP> rgr@m10ux.UUCP (Duke Robillard) writes:
		[some stuff deleted]
>
>But with a *real* implementation of data hiding, you wouldn't have to
>go back through that long chain of garbage.  To set some variable of
>type foo, you'd call a function called set_foo.  To print the time,
>you'd call a routine called print_time_t.  This is a major concept 
>behind "object oriented programming" languages, like smalltalk or (maybe)
>C++.
>

(Please follow this up to comp.lang.misc)

I really hated doing this back in the days when I programmed in Modula-2.  I
ended up having a lot of functions which did nothing but set and read
variables.  Unless you have a real smart optimizing compiler, using function
calls instead of just referencing the variables has a large cost associated
with it.  (Yes, I know that in some situations you would rather have function
calls because you can check for a legal value, valid range, etc., but that is
another story.)

Also, in order to use time_t (besides just printing it out), I do need to know
what type it is.

BTW, if you really need to do data hiding in C, you can use external static
variables and write functions to access them (see K&R section 4.6).
-- 
 _ __			NEVIN J. LIBER	..!ihnp4!ihlpf!nevin1	(312) 510-6194
' )  )				"The secret compartment of my ring I fill
 /  / _ , __o  ____		 with an Underdog super-energy pill."
/  (_</_\/ <__/ / <_	These are solely MY opinions, not AT&T's, blah blah blah