CS/CE 218 Lecture -*- Outline -*- connection: you are now C programmers, and Unix programmers. If you wish you may go on to be a guru. In any case, we have touched on several themes in the course, and it's time to step back from the trees and view the forest. * Summary of the course, especially the C part ** Main (philosophical) points of the course *** think abstractly: that is, code at a high level to do this, you write (or find) code for the abstractions you want, then write rest of the program in terms of those abstractions e.g., write functions to manipulate bits, use stdio library functions to do I/O, buffering, etc. a bigger organizing idea is abstract data types, organize your function abstractions around a data structure *** avoid redundancy use variables, definitions, macros, functions, makefiles, etc. *** information hiding set up boundaries between different parts of your program, don't allow decisions (about data structures, algorithms, etc.) to be spread throughout your programs. *** prototyping it is often useful to evolve a function from a simple shell program to a more complex one, and if efficiency warrants, a C program best to use this: when you don't know what you want (if you've never written anything like this before, or if your customer has never had this before) limitations of this approach: expensive, because you often throw out a lot of code, => don't use if the problem is well understood *** tools and the Unix philosophy don't start with a complete "system" solution to your problems best to build small tools that do one job well, instead of swiss army knives why? because it's hard to build a good swiss army knife examples: grep, cut, paste, ... Q: What C programs did we see that were tool-like? grade_estimate, word_freq, emacs_std_outline, options, print_errors, ... limitations: sometimes a system is more than the sum of its parts e.g., display editors like emacs ** Problems left open by the course *** How to plan and think about programming we started talking about this, but it's a lifelong problem you can always learn more about this, and everything you learn will help you do better work with less effort *** How to specify a programming problem clearly and unambiguously interesting mathematical aspects (e.g., logic) *** Is C the best language for your work? what are the limitations of C, what are it's advantages? how could we do it better *** Could you design a better shell? e.g., could you design something that is more intuitive, but still has the power of pipelines, etc. ** How to go on *** Project vincent Anyone can get a vincent account, walk up to a machine in the vincent section of Durham, 1st floor terminal room register by clicking on the buttons get a copy of the project vincent user's guide from the room next to the micro computer products center *** reference material in the textbook you probably haven't used the text much as a reference yet, but it's quite good at that. look at appendix A, this has concise answers to questions; it's worth reading it once to understand it's language, then you can use it better to answer questions as you program For example, Can I write 3.0E+3 as a constant? (page 194) What does void mean? What does (void) fclose(fp) mean? What does (void *) mean? (page 199) What exactly is a constant expression? (page 209) Does the # in #define have to be in column 1? (page 228) etc. look at appendix B, which may be more useful it has a summary of all the stuff in the standard library and the header files. standard library is also found on-line in section 3 e.g., man 3 feof *** Other books ------------------------ The UNIX Programming Environment, B. W. Kernighan and R. Pike (Prentice-Hall 1984) has more examples of shell programming, C programs, tools, yacc Writing Efficient Programs, J. L. Bentley (Prentice-Hall 1982) Programming Pearls, J. L. Bentley (Addison-Wesley, 1986) More Programming Pearls, J. L. Bentley (Addison-Wesley, 1988) Software Tools, B. W. Kernighan and P. J. Pike (Addison-Wesley, 1976) ------------------------ *** Other courses if you liked the software process aspects, look forward to CS 411 if you enjoyed learning a new language, look forward to CS 342 ** Personal remarks Thanks for the teaching feedback.