comparison unix-phil.ms @ 41:13ef7042fa28

some rework in ch01; nicer formating
author meillo@marmaro.de
date Fri, 09 Apr 2010 12:44:08 +0200
parents 422679bdf384
children 303e8f449e77
comparison
equal deleted inserted replaced
40:422679bdf384 41:13ef7042fa28
1 .\".if n .pl 1000i
2 .nr PS 11 1 .nr PS 11
3 .nr VS 13 2 .nr VS 13
4 .de XX
5 .pl 1v
6 ..
7 .em XX
8 .\".nr PI 0
9 .\".if t .nr PD .5v
10 .\".if n .nr PD 1v
11 .nr lu 0 3 .nr lu 0
12 .de CW 4 .de CW
13 .nr PQ \\n(.f 5 .nr PQ \\n(.f
14 .if t .ft CW 6 .if t .ft CW
15 .ie ^\\$1^^ .if n .ul 999 7 .ie ^\\$1^^ .if n .ul 999
33 and thus a lot of modern software is more limited than necessary 25 and thus a lot of modern software is more limited than necessary
34 and makes less use of software leverage than possible. 26 and makes less use of software leverage than possible.
35 Knowing and following the guidelines of the Unix Philosophy makes software more valuable. 27 Knowing and following the guidelines of the Unix Philosophy makes software more valuable.
36 .AE 28 .AE
37 29
38 .\".if t .2C
39
40 .FS 30 .FS
41 .ps -1 31 .ps -1
42 This paper was prepared for the ``Software Analysis'' seminar at University Ulm. 32 This paper was prepared for the ``Software Analysis'' seminar at University Ulm.
43 Mentor was professor Schweiggert. 2010-04-05 33 Mentor was professor Schweiggert. 2010-04-05
44 .br 34 .br
62 %P Wikipedia, The Free Encyclopedia 52 %P Wikipedia, The Free Encyclopedia
63 %D 2010-03-21 17:20 UTC 53 %D 2010-03-21 17:20 UTC
64 %O .CW \s-1http://en.wikipedia.org/w/index.php?title=Unix_philosophy&oldid=351189719 54 %O .CW \s-1http://en.wikipedia.org/w/index.php?title=Unix_philosophy&oldid=351189719
65 .] 55 .]
66 .QP 56 .QP
57 .ps -1
67 The \fIUnix philosophy\fP is a set of cultural norms and philosophical 58 The \fIUnix philosophy\fP is a set of cultural norms and philosophical
68 approaches to developing software based on the experience of leading 59 approaches to developing software based on the experience of leading
69 developers of the Unix operating system. 60 developers of the Unix operating system.
70 .PP 61 .PP
71 As there is no single definition of the Unix Philosophy, 62 As there is no single definition of the Unix Philosophy,
109 100
110 .PP 101 .PP
111 The Unix Philosophy tells how to design and write good software for Unix. 102 The Unix Philosophy tells how to design and write good software for Unix.
112 Many concepts described here base on facilities of Unix. 103 Many concepts described here base on facilities of Unix.
113 Other operating systems may not offer such facilities, 104 Other operating systems may not offer such facilities,
114 hence it may not be possible to design software is the way of the Unix Philosophy. 105 hence it may not be possible to design software in the way of the
115 106 Unix Philosophy for them.
116 FIXME 107 .PP
117 108 The Unix Philosophy has an idea of how the process of software development
118 This paper discusses the recommendations of the Unix Philosophy about software design. 109 should look like, but large parts of the philosophy are quite independent
119 .PP 110 from the development process used.
120 The here discussed ideas can get applied by any development process. 111 However, one will soon recognize that some development processes work well
121 The Unix Philosophy does recommend how the software development process should look like, 112 with the ideas of the Unix Philosophy and support them, while others are
122 but this shall not be of matter here. 113 at cross-purposes.
123 Similar, the question of how to write the code is out of focus. 114 Kent Beck's books about Extreme Programming are valuable supplimental
124 .PP 115 resources.
125 Before we will have a look at concrete concepts, 116 .PP
126 we discuss why software design is important 117 The question of how to actually write code and how the code should looks
127 and what problems bad design introduces. 118 like internally, are out of focus here.
128 119 ``The Practice of Programming'' by Kernighan and Pike,
120 .[
121 %A Brian W. Kernighan
122 %A Rob Pike
123 %T The Practice of Programming
124 %I Addison-Wesley
125 %D 1999
126 .]
127 is a good book that covers this topic.
128 Its point of view matches to the one of this paper.
129 129
130 .NH 1 130 .NH 1
131 Importance of software design in general 131 Importance of software design in general
132 .LP 132 .LP
133 Software design is the planning of how the internal structure 133 Software design is the planning of how the internal structure
253 .LP 253 .LP
254 Following are some examples to demonstrate how applied Unix Philosophy feels like. 254 Following are some examples to demonstrate how applied Unix Philosophy feels like.
255 Knowledge of using the Unix shell is assumed. 255 Knowledge of using the Unix shell is assumed.
256 .PP 256 .PP
257 Counting the number of files in the current directory: 257 Counting the number of files in the current directory:
258 .DS I 2n 258 .DS
259 .CW 259 .CW
260 .ps -1 260 .ps -1
261 ls | wc -l 261 ls | wc -l
262 .DE 262 .DE
263 The 263 The
266 and 266 and
267 .CW "wc -l 267 .CW "wc -l
268 counts the number of lines. 268 counts the number of lines.
269 .PP 269 .PP
270 Counting the number of files that do not contain ``foo'' in their name: 270 Counting the number of files that do not contain ``foo'' in their name:
271 .DS I 2n 271 .DS
272 .CW 272 .CW
273 .ps -1 273 .ps -1
274 ls | grep -v foo | wc -l 274 ls | grep -v foo | wc -l
275 .DE 275 .DE
276 Here, the list of files is filtered by 276 Here, the list of files is filtered by
277 .CW grep 277 .CW grep
278 to remove all that contain ``foo''. 278 to remove all that contain ``foo''.
279 The rest is the same as in the previous example. 279 The rest is the same as in the previous example.
280 .PP 280 .PP
281 Finding the five largest entries in the current directory. 281 Finding the five largest entries in the current directory.
282 .DS I 2n 282 .DS
283 .CW 283 .CW
284 .ps -1 284 .ps -1
285 du -s * | sort -nr | sed 5q 285 du -s * | sort -nr | sed 5q
286 .DE 286 .DE
287 .CW "du -s * 287 .CW "du -s *
429 No complexity is added this way, 429 No complexity is added this way,
430 but new programs can get created out of existing one with very low effort. 430 but new programs can get created out of existing one with very low effort.
431 .PP 431 .PP
432 A wrapper script for finding the five largest entries in the current directory 432 A wrapper script for finding the five largest entries in the current directory
433 could look like this: 433 could look like this:
434 .DS I 2n 434 .DS
435 .CW 435 .CW
436 .ps -1 436 .ps -1
437 #!/bin/sh 437 #!/bin/sh
438 du -s * | sort -nr | sed 5q 438 du -s * | sort -nr | sed 5q
439 .DE 439 .DE
440 The script itself is just a text file that calls the command line 440 The script itself is just a text file that calls the command line
441 a professional user would type in directly. 441 a professional user would type in directly.
442 Making the program flexible on the number of entries it prints, 442 Making the program flexible on the number of entries it prints,
443 is easily possible: 443 is easily possible:
444 .DS I 2n 444 .DS
445 .CW 445 .CW
446 .ps -1 446 .ps -1
447 #!/bin/sh 447 #!/bin/sh
448 num=5 448 num=5
449 [ $# -eq 1 ] && num="$1" 449 [ $# -eq 1 ] && num="$1"
493 %P 1069\(en1076 493 %P 1069\(en1076
494 %I Elsevier Science B.V. 494 %I Elsevier Science B.V.
495 %C Amsterdam, The Netherlands 495 %C Amsterdam, The Netherlands
496 .] 496 .]
497 .QP 497 .QP
498 .ps -1
498 The hardest single part of building a software system is deciding precisely what to build. 499 The hardest single part of building a software system is deciding precisely what to build.
499 No other part of the conceptual work is so difficult as establishing the detailed 500 No other part of the conceptual work is so difficult as establishing the detailed
500 technical requirements, [...]. 501 technical requirements, [...].
501 No other part of the work so cripples the resulting system if done wrong. 502 No other part of the work so cripples the resulting system if done wrong.
502 No other part is more difficult to rectify later. 503 No other part is more difficult to rectify later.
642 %O FIXME 643 %O FIXME
643 %A Allman 644 %A Allman
644 %T sendmail 645 %T sendmail
645 .] 646 .]
646 .QP 647 .QP
648 .ps -1
647 Second, I limited myself to the routing function [...]. 649 Second, I limited myself to the routing function [...].
648 This was a departure from the dominant thought of the time, [...]. 650 This was a departure from the dominant thought of the time, [...].
649 .QP 651 .QP
652 .ps -1
650 Third, the sendmail configuration file was flexible enough to adopt 653 Third, the sendmail configuration file was flexible enough to adopt
651 to a rapidly changing world [...]. 654 to a rapidly changing world [...].
652 .LP 655 .LP
653 Successful software adopts itself to the changing world. 656 Successful software adopts itself to the changing world.
654 .PP 657 .PP
904 and 907 and
905 .B "do one thing well 908 .B "do one thing well
906 are two design goals that are directly visible in \s-1MH\s0. 909 are two design goals that are directly visible in \s-1MH\s0.
907 Gancarz actually presents \s-1MH\s0 as example under the headline 910 Gancarz actually presents \s-1MH\s0 as example under the headline
908 ``Making UNIX Do One Thing Well'': 911 ``Making UNIX Do One Thing Well'':
912 .[
913 %A Mike Gancarz
914 %T unix-phil
915 %P 125
916 .]
909 .QP 917 .QP
918 .ps -1
910 [\s-1MH\s0] consists of a series of programs which 919 [\s-1MH\s0] consists of a series of programs which
911 when combined give the user an enormous ability 920 when combined give the user an enormous ability
912 to manipulate electronic mail messages. 921 to manipulate electronic mail messages.
913 A complex application, it shows that not only is it 922 A complex application, it shows that not only is it
914 possible to build large applications from smaller 923 possible to build large applications from smaller
915 components, but also that such designs are actually preferable. 924 components, but also that such designs are actually preferable.
916 .[
917 %A Mike Gancarz
918 %T unix-phil
919 %P 125
920 .]
921 .LP 925 .LP
922 The various small programs of \s-1MH\s0 were relatively easy 926 The various small programs of \s-1MH\s0 were relatively easy
923 to write, because each of them is small, limited to one function, 927 to write, because each of them is small, limited to one function,
924 and has clear boundaries. 928 and has clear boundaries.
925 For the same reasons, they are also good to maintain. 929 For the same reasons, they are also good to maintain.
1062 long time ago for \s-1MH\s0. 1066 long time ago for \s-1MH\s0.
1063 But without following this guideline at the very beginning, 1067 But without following this guideline at the very beginning,
1064 Bruce Borden may have not convinced the management of \s-1RAND\s0 1068 Bruce Borden may have not convinced the management of \s-1RAND\s0
1065 to ever create \s-1MH\s0. 1069 to ever create \s-1MH\s0.
1066 In Bruce' own words: 1070 In Bruce' own words:
1071 .[
1072 %O FIXME
1073 .]
1067 .QP 1074 .QP
1075 .ps -1
1068 [...] but they [Stockton Gaines and Norm Shapiro] were not able 1076 [...] but they [Stockton Gaines and Norm Shapiro] were not able
1069 to convince anyone that such a system would be fast enough to be usable. 1077 to convince anyone that such a system would be fast enough to be usable.
1070 I proposed a very short project to prove the basic concepts, 1078 I proposed a very short project to prove the basic concepts,
1071 and my management agreed. 1079 and my management agreed.
1072 Looking back, I realize that I had been very lucky with my first design. 1080 Looking back, I realize that I had been very lucky with my first design.
1075 with key structures and wrote the first few \s-1MH\s0 commands: 1083 with key structures and wrote the first few \s-1MH\s0 commands:
1076 inc, show/next/prev, and comp. 1084 inc, show/next/prev, and comp.
1077 [...] 1085 [...]
1078 With these three, I was able to convince people that the structure was viable. 1086 With these three, I was able to convince people that the structure was viable.
1079 This took about three weeks. 1087 This took about three weeks.
1080 .[
1081 %O FIXME
1082 .]
1083 1088
1084 .NH 2 1089 .NH 2
1085 Problems 1090 Problems
1086 .LP 1091 .LP
1087 \s-1MH\s0, for sure is not without problems. 1092 \s-1MH\s0, for sure is not without problems.