home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / doc / mir / 12source < prev    next >
Text File  |  1992-06-29  |  19KB  |  392 lines

  1.  
  2.               ══════════════════════════════════════
  3.  
  4.                     2.  SOURCE CODE GUIDELINES
  5.  
  6.               ══════════════════════════════════════
  7.  
  8.  
  9.             The objective of this unit is to set a framework in
  10. which you are invited to use, respond to, and improve upon, the
  11. techniques and software in the MIR series.
  12.  
  13.  
  14.         ═════════════════════════════════════════════
  15. 2.1           Needs of the information searcher
  16.         ═════════════════════════════════════════════
  17.  
  18.             Good software is user- or market-driven.  (We've said
  19. that before!)  At this point let's take a closer look at the needs
  20. of a potential user, putting ourselves in the place of a person who
  21. wants to retrieve information quickly and easily from large masses
  22. of data.  What are the things that matter?  The following items are
  23. mentioned again and again.
  24.  
  25.  
  26.             The value of time:  The time factor shows up in two
  27. ways... learning and system response.
  28.  
  29.             If it takes a course or five days of seminars to learn
  30. how to use a program, most potential users are frightened away. 
  31. Buyer resistance sets in if the salesperson doesn't invite you to
  32. take over early in a demonstration.  People don't even want to take
  33. the time to read a manual; the majority rarely do!
  34.  
  35.             System response has to do with how much time elapses
  36. until the program reacts to a new instruction from the user.  If a
  37. computer program replaces a manual method that took far longer,
  38. people tolerate delays... at first.  But over a few months of use,
  39. they grow impatient with slow response.  For long term comfort and
  40. acceptance, three quarters of a second seems to be the threshold of
  41. tolerance.  You might think in terms of a "three-quarters of a
  42. second, 95% of the time" rule for computer programming.  In other
  43. words, make sure that the program, at least 19 times out of 20,
  44. shows some response to new instructions from the user within three-
  45. quarters of a second.  That standard is not as difficult to achieve
  46. as it might appear.
  47.  
  48.  
  49.  
  50.             Simplicity, simplicity, simplicity:  How do we feel
  51. about a computer program that requires combinations of two or three
  52. keys, such as ALT-Shift-H to get help?  Or a program where we
  53. search in vain for any logic or consistency in the instruction set? 
  54. So long as we have "user friendly" software like that, we need no
  55. enemies.
  56.  
  57.             Simplicity reduces learning time.  Simplicity rescues
  58. the user from becoming hostage to the manual or to instruction
  59. summary cards (especially after not having used the program for a
  60. few weeks).  Uniform simplicity across many programs is even
  61. better, because the user becomes free to move easily from one
  62. program to another.  To the computer firms that promote intuitive,
  63. uniform simplicity, a vote of thanks!
  64.  
  65.             Achieving simplicity for the user places extra demands
  66. on the designer and programmer.  But the trade-off between those
  67. demands and the costs of turning hundreds or thousands of potential
  68. users into reluctant technicians is no contest at all.  Programmers
  69. and designers, go the second mile and make it easy for the user. 
  70. The marketplace in the long run will reward you for it.
  71.  
  72.             The argument against simplicity is that programs will
  73. lack power that more sophisticated users demand.  The answer to
  74. that is to bury the extra power in segments of the program or
  75. behind optional instructions or menus so that they do not intrude
  76. on the person who does not want or is not ready for the extra
  77. features.  And when the extra features are turned on, still keep it
  78. simple!
  79.  
  80.  
  81.             Control:  Who is in control... the program or the
  82. person running it?  The program is in control:
  83.  
  84.     »       if it is possible to get locked into a situation from
  85.             which there is no escape except through reading large
  86.             sections of the manual (or rebooting);
  87.  
  88.     »       if the person has to tab through several fields to get
  89.             to the next place where data is to be changed or added;
  90.  
  91.     »       if the user is forced to traverse a maze of menus   
  92.             long after becoming familiar with the program;
  93.  
  94.     »       if it takes more than two or three keystrokes or    
  95.             mouse-clicks to quit the program from anywhere
  96.             whatsoever within the program;.
  97.  
  98.             These are examples only.  People like the feeling that
  99. they themselves are running things, not some faceless programmer or
  100. designer.
  101.  
  102.  
  103.             Freedom from a ticking clock:  One feature of
  104. centralized processing is calculated to devastate the human
  105. psyche... the message when logging out that one has used several
  106. hundred dollars worth of computer time.  It rarely hits the
  107. worker's wallet directly, but the message is still received...
  108. guilt, guilt, guilt.  It takes the fun out of computer use.
  109.  
  110.             This need argues for more efficient programs.  In the
  111. case of centralized processing, the task is finished faster and the
  112. computer resources and any communication costs are lower.  Truly
  113. efficient programs open the way to distributed processing, where
  114. the user can leave a personal computer running for hours at a
  115. marginal cost of only a few cents for electricity.  Communication
  116. costs are nil.  Guilt over the ticking clock is gone.
  117.  
  118.  
  119.             Freedom from obscure error messages:  Capital
  120. punishment is outside the scope of tutorials on indexing and
  121. retrieval.  But isn't there a feeling of moral satisfaction in
  122. considering the ultimate deterrent for programmers who wish upon us
  123. in mid-program gems like: "CANNOT ALLOC MORE MEMORY"?  Somewhat
  124. worse are the error messages that seem to be in plain language, but
  125. you find out that the content has nothing to do with the actual
  126. problem.
  127.  
  128.  
  129.             Freedom from the curse of codes:  What's wrong with
  130. plain language?
  131.  
  132.  
  133.             Language of choice:  There are two ways for programmers
  134. to accommodate users' preference for programs operating in their
  135. native language.  For programs that are not interactive, it is
  136. sufficient if source code is available so that error messages and
  137. the program description message can be translated and the program
  138. recompiled.  A well written interactive program has all its screen
  139. text, prompts, instructions and help messages in a separate file. 
  140. This text file may be translated into other languages.  Careful
  141. attention must be paid to spacing so that messages fit on the
  142. screen in the space assigned by the program.  These files are then
  143. named according to a convention that is easily recognized by the
  144. program.  Example:  ENGLISH.LNG, ESPANOLA.LNG, FRANCAIS.LNG, etc. 
  145. If only one file is present, the program automatically appears in
  146. that language only.  If multiple such files are in the same
  147. computer directory, the user is offered a choice of languages
  148. immediately when the program starts up.
  149.  
  150.  
  151.             Context-sensitive help:  This feature has become quite
  152. common.  The program user may touch a single key (often the F1
  153. function key on personal computers) to get helpful instructions. 
  154. These help messages are context-sensitive if their content depends
  155. on what options are open at that point in the program.
  156.  
  157.  
  158.             More bang per computer dollar:  Personal computers have
  159. revolutionized the economics of information.  Where access is
  160. needed to up-to-the-minute data (such as seats available on an
  161. airline flight), processing has to be centralized on large
  162. machines.  That's expensive... the central mainframe computers, the
  163. communications costs, and the ability to transact data changes that
  164. become accessible to other people immediately.  Personal computers
  165. come into their own where data can be downloaded or distributed,
  166. and used at the individual's pleasure.  You don't need a million
  167. dollar computer to search using an index; a personal computer
  168. costing less than a thousand dollars is capable of nearly instant
  169. response.  Even the complex task  of creating an index for a large
  170. quantity of data requires only a moderate amount of computer
  171. "horsepower."  Personal computers can carry out quite sophisticated
  172. chores.  For example, statistical analysis of survey questionnaires
  173. is in some cases a simple extension of the use of high speed
  174. indexes.
  175.  
  176.  
  177.         ═════════════════════════════
  178. 2.2           Design background
  179.         ═════════════════════════════
  180.  
  181.             Every computer program represents a series of design
  182. decisions.  In order to understand more readily MIR technology and
  183. software, you may find some background helpful.
  184.  
  185.             Squeezing each bit... the conservationist start:  I
  186. first programmed in 1964 on an IBM 1440 which had 4,096 bytes of
  187. available RAM.  That's for the program and the data.  One quickly
  188. develops a mindset under these conditions... make every bit within
  189. every byte count for as much as possible.  During the 1970s the
  190. prevailing attitude was to pour hardware resources lavishly on any
  191. computer problem.  I didn't get on the bandwagon.  Effectiveness
  192. and efficiency still mattered.  For example, when developing an
  193. early fourth generation language, I took a kind of perverse pride
  194. in squeezing data types into minimum byte counts...  dates in 16
  195. bits, postal and zip codes coexisting in 27 bits, area codes and
  196. telephone numbers in 31 bits (achieved by swapping the first two
  197. digits in the area code; it works because the second digit of an
  198. area code is zero or one).
  199.  
  200.             The gigabyte years:  Since early in the 1980s the
  201. majority of my computer work has been in connection with databases
  202. in the sixty million to 3 billion byte range.  The CD-ROM world
  203. seemed an invitation to be extravagant; space is plentiful.  But
  204. efficiency has an interesting payoff.  It affects retrieval
  205. timings.  Why go out to the disc multiple times or why take the
  206. time to fill huge buffers on each access?  Working with compressed
  207. indexes reduces mechanical head movement, by far the greatest time
  208. factor.  And compressed indexes can be used for remarkably faster
  209. Boolean operations.  More on that later.
  210.  
  211.             UNIX influence:  I created the database system that
  212. later became known as FindIT under the Primos operating system,
  213. then shifted in 1985 to UNIX.  Predecessor versions of many MIR
  214. software routines were written in the UNIX environment.  One moves
  215. in a world of byte streams, pipes, and bit manipulation.  DOS by
  216. contrast is oriented toward printable data; witness the fact that
  217. binary data requires special declaration in DOS and cannot be fed
  218. through pipes.  (Stdin and stdout in DOS insert a carriage return
  219. in the data whenever DOS encounters a binary byte which happens to
  220. be a linefeed; behavior when a binary CTL-Z is found is even more
  221. unpleasant.)  The MIR programs are DOS versions, but the UNIX-style
  222. thinking will show through.
  223.  
  224.             C with a FORtran accent:  It's common to learn a
  225. variety of languages when involved with computer programming over
  226. an extended period.  My early set included Autocoder, Assembler,
  227. Basic, Cobol, and various forms of machine language.  FORtran was
  228. my language of choice from 1968 to 1985.  That long in one language
  229. gives one an accent when moving on into another language.  C
  230. language was the logical choice for portability and for efficient
  231. control over byte streams.  FORtran doesn't promote modularity as
  232. much as C; it's more linear in its thought forms.  A C purist might
  233. be shocked at inelegancies and "FORtranisms" in my C code.  Fair
  234. enough, but remember that it works!  (As Billy Sunday is reputed to
  235. have answered a critic:  "I like the way I'm doing it better than
  236. the way you are not doing it.")
  237.  
  238.  
  239.  
  240. ≡≡≡≡->> QUESTION:
  241.             If you are expert in C++ or in any approach to object
  242.             oriented software, you are strongly encouraged to
  243.             provide alternative coding to any programs offered in
  244.             MIR.  Object oriented software is gaining ground
  245.             rapidly.  C++ language is nearing critical mass in
  246.             terms of acceptance and numbers of people competent in
  247.             its use.
  248.                                                             <<-≡≡≡≡
  249.  
  250.  
  251.         ════════════════════════════
  252. 2.3           Design decisions
  253.         ════════════════════════════
  254.  
  255.             Here then are design decisions that are built into MIR
  256. software.  You are not bound by them.  But they affect you to the
  257. extent you may use this material as a starting point.
  258.  
  259.             Language:  C language is currently the language of
  260. choice for widest portability, at least in North America, and
  261. probably the world.  It offers somewhat less power than Assembler
  262. and less clarity than Basic.  C doesn't get the preferential
  263. treatment given to Pascal in the Macintosh environment. 
  264. Nonetheless C is likely to serve the needs of the widest spectrum
  265. of potential users of computerized indexing and retrieval.
  266.  
  267.             Hardware:  The executable versions are compiled for use
  268. on IBM-compatible personal computers.  This starting point provides
  269. the widest access, since there are more PCs around than all others
  270. put together.
  271.  
  272.             Operating system and compiler:  Again, access by the
  273. widest number of potential users favors DOS.  I am using
  274. Microsoft's Version 5.0 in combination with the Microsoft C 6.0
  275. Programmer's Workbench compiler.  Switches are set for ANSI C (to
  276. eliminate code unique to Microsoft C) and 8086 runtime operability.
  277.  
  278.             Avoiding code that blows up:  Some practices, while
  279. common in C language, lead to messy situations when porting to
  280. other environments.  For example, the "varargs.h" files in Sun and
  281. DOS differ; the use of "varargs.h" leads to inconsistencies when
  282. moving from one computer to the other.  Therefore variable argument
  283. routines are not used.  (One price... warning and error routines
  284. are less elegant.)  Dynamic memory allocation also has been
  285. dropped.  (Sorry about that.)  And as discussed earlier, the
  286. vagaries of DOS reduce dramatically the ability to pipe binary byte
  287. streams.  Stdin and stdout have been used only when there is
  288. reasonable certainty that printable files only are involved.  To
  289. anyone working in UNIX, feel free to change back; then you can use
  290. series of pipes and avoid the successive creation and deletion of
  291. work files.
  292.  
  293.  
  294.  
  295.         ═══════════════════════
  296. 2.4           Conventions
  297.         ═══════════════════════
  298.  
  299.             Humans use programs:  Any MIR program responds with an
  300. explanation, up to one screen in length, detailing what the program
  301. is intended to do and what arguments it expects.  If you wish to
  302. see this quick overview for any program, input the program name
  303. followed by a space and either /U or a question mark.  Example:
  304.  
  305.                 A_BYTES ?
  306.  
  307.             Normal courtesy to the end user of a program suggests
  308. that we avoid inhuman messages, either obscure or misleading.  By
  309. the same token, no program is to have an inescapable situation,
  310. that is, one that gives no direction to the user how to undo a path
  311. or leave a program.  Depending on handlers installed, CTL-C may or
  312. may not act as an escape.  The most reliable approach is to write
  313. code so that the program always responds to the escape key (ESC).
  314.  
  315.             Humans read programs:  Brian Kernighan and Dennis
  316. Ritchie are undoubtedly very fine fellows.  Whatever induced them
  317. to inflict on humanity their weird convention in placing brace
  318. brackets?  Programs should be for people in every way... including
  319. readability for programmers.  In MIR C code, matching brace
  320. brackets are always vertically aligned and their content indented
  321. so that one can see at a glance their range.
  322.  
  323.             Comments, reasonable variable names, descriptive
  324. declarations, full descriptions at the top of source code as to
  325. function, input and output all add to the usefulness of programs.
  326.  
  327.  
  328.         ══════════════════════════════
  329. 2.5           Use it, improve it
  330.         ══════════════════════════════
  331.  
  332.             Let's turn to what you might do with this material.
  333.  
  334.             It's here for you to use.  No royalties need be paid to
  335. anyone.  Identify your needs in the area of indexing and retrieval,
  336. then select from what is offered in successive MIR tutorial
  337. releases to match your needs.
  338.  
  339.             As a first time user, you have something of value... a
  340. fresh perspective.  Are there parts of the tutorials that you find
  341. confusing?  Which programs warrant more explanation?  May parts be
  342. safely omitted?  Please share your thoughts!  An ASCII text file
  343. "RESPONSE" is included on the diskettes with this tutorial.  Make
  344. a copy of "RESPONSE", edit in your comments, and send it by FAX,
  345. electronic mail, or regular mail to an address listed at the bottom
  346. of the RESPONSE template.  (Addresses also appear near the top of
  347. each source code listing.)
  348.  
  349.             You may have noticed on the copyright page and response
  350. template that Marpex has not invited telephone calls.  This is not
  351. a discourtesy, but a protection.  FAX and electronic mail permit
  352. time shifting; the voice phone does not.  I recommend to you a
  353. little book entitled "Peopleware: Productive Projects and Teams"
  354. (Tom DeMarco and Timothy Lister... New York: Dorset Publishing
  355. House, 1987).  Look especially at Chapter 8: "You Never Get
  356. Anything Done Around Here Between 9 and 5", and Chapter 11: "The
  357. Telephone".
  358.  
  359.             Note that the tutorials and the source code are made
  360. available to you under two different sets of rules.  The tutorials
  361. are shareware; they may be freely copied, but not changed.  Your
  362. suggestions concerning the text should be sent to the author. 
  363. Under "copyleft" rules, the source code may be changed and
  364. redistributed widely.  As a courtesy, please share your source code
  365. changes and new programs with us.  We will add all the material
  366. that seems relevant and helpful to later releases.  All software
  367. that you provide must, of course, come under the copyleft rules in
  368. order for us to distribute it.  (And please, please, please, send
  369. us only source code for which you have rights to share.)
  370.  
  371.             If you work on different equipment and/or under a
  372. different operating system, you are invited to port the code to
  373. that environment.  In the final CD-ROM version we will set up
  374. subdirectories as needed for alternate operating systems. 
  375. Incidentally, the port to Sun Microsystems UNIX is very simple:
  376. take the binary flags out of file opening sequences, and increase
  377. the #define statements if you want larger buffers.
  378.  
  379.             Please send source code in machine readable form -
  380. either by electronic mail or on a floppy diskette by regular mail. 
  381. To get maximum attention for your efforts, please observe the
  382. conventions for software outlined above.
  383.  
  384. ≡≡≡≡->> QUESTION:
  385.             Are there ways we could improve this process, and still
  386.             stick to the schedule of releases and the copyleft
  387.             ground rules?  Your thoughts, please.
  388.                                                             <<-≡≡≡≡
  389.  
  390.  
  391.             This is the shape of cooperative development.  Join in,
  392. share, have fun.