Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site umcp-cs.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!umcp-cs!chris From: chris@umcp-cs.UUCP (Chris Torek) Newsgroups: net.lang.c Subject: Re: Unix/C program modularity Message-ID: <1898@umcp-cs.UUCP> Date: Thu, 17-Oct-85 20:14:58 EDT Article-I.D.: umcp-cs.1898 Posted: Thu Oct 17 20:14:58 1985 Date-Received: Sat, 19-Oct-85 07:22:18 EDT References: <637@dicomed.UUCP> Organization: U of Maryland, Computer Science Dept., College Park, MD Lines: 63 [This is in response to article <637@dicomed.UUCP> by papke@dicomed.UUCP (Kurt Papke).] Perhaps I should not speak of it, since I have not been involved in any of the actual coding, but I believe I know of a counterexample. The Center for Automation Research (nee Computer Vision Laboratory), umcp-cs!cvl, has a very large body of reusable code: the CVL picture library. I do not, however, know much about this, so I well be wrong. But in any case, I think you have, as the saying goes, lost sight of the forest for the trees. Why *should* Unix programmers write reusable code for each program? Instead, or perhaps in addition but more importantly, Unix programmers should---and at times do--- write reusable *programs*. The very `Unix Philosophy' of which you speak is that you should create a set of tools which can be used together to solve many problems, though each tool solves only a subset of any one problem. To give an example, however contrived or even erroneous---as I mentioned, I do not work for CfAR---consider taking a set of picture files, performing some algebraic transformation on each pixel value, applying histogram equalization, then halftoning and printing on an Imagen laser printer: for i in *.pict; do lop "your operation here" < $i | histeq | ht | pi | qpr -q imagen-imp done (I have made up some of these program names; CVL people may correct me if I have important details wrong. `lop' stands for Local Operation on Picture, by the way.) If instead you need to display one of these on the Grinnell: lop "your operation here" < foo.pict | histeq | ht | put "params" or without halftoning: grey # Grinnel to B/W display lop "your operation here" < foo.pict | histeq | put "params" The point of all this is that reuse of code itself is unnecessary if the code is in a separate program. All you need do insert the program at the appropriate point in the pipe. Now, if you are talking about applying the same operation to thousands of pictures a day, then (and *only* then) you should consider taking the `guts' of each operation out of each of the programs in question, building argument and error handling around them, and packaging that up as an `application'. I have tried to keep my response within the domain of computer graphics, as that was the focus of your article; graphics has not been one of my studies, and I ask those who are more knowledgeable to forgive glaring errors, or to quitely correct them (i.e., `flames to /dev/null'). But my point---that Unix *programs* should be reusable---applies to many domains. A proper set of tools is an invaluable asset in any line of work. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251) UUCP: seismo!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@mimsy.umd.edu