Sie sind auf Seite 1von 4

Quotes

There is no programming language, no matter how structured, that will prevent programmers from writing bad programs. L. Flon A journey of a thousand miles must begin with a single step. Lao-zi If carpenters made buildings the way programmers make programs, the first woodpecker to come along would destroy all of civilization. Weinberg's Second Law Once a decision was made, I did not worry about it afterward. Harry Truman The speech of man is like embroidered tapestries, since like them this has to be extended in order to display its patterns, but when it is rolled up it conceals and distorts them. Themistocles Total grandeur of a total edifice, Chosen by an inquisitor of structures. Wallace Stevens The choice of a point of view is the initial act of culture. Jos Ortega y Gasset A race that binds Its body in chains and calls them Liberty, And calls each fresh link progress. Robert Buchanan For there isn't a job on the top of the earth the beggar don't know, nor do. Rudyard Kipling

Style
Style is the most important part of programming. Style is what separates the gems from the junk. It is what separates the programming artist from the butcher. You must learn good programming style first, before typing in your first line of code, so that everything you write will be of the highest quality. A working but uncommented program is a time bomb waiting to explode. Sooner or later, someone will have to fix a bug in the program, modify it, or upgrade it, and the lack of comments will make the job much more difficult. A well-commented, simple program is a work of art. Learning how to comment is as important as learning how to code properly. In order to write a program, you must have a clear idea of what you are going to do. One of the best ways to organize your thoughts is to write them down in a language that is clear and easy to understand. After the process has been clearly stated, it can be translated into a computer program. Your program should read like an essay. It should be as clear and easy to understand as possible. Good programming style comes from experience and practice. The list that follows contains some of the sections that should be included at the beginning of your program. Not all programs will need all sections, so use only those that apply: 1. Heading Name of the program/a short description of what the program does 2. Author You've gone to a lot of trouble to create this program. Take credit for it. Also, anyone who has to modify the program can come to you for information and help. 3. Purpose Why did you write this program? What does it do? 4. Usage Short explanation of how to run the program 5. References Creative copying is a legitimate form of programming (don't break the copyright laws in the process). Reference the original author of any work you copied. 6. File formats List the files that program reads or writes and a short description of their formats. 7. Restrictions List any limits or restrictions that apply to the program, such as "The program does not check for input errors." 8. Revision history List indicating who modified the program, and when and what changes were made. 9. Error handling If the program detects an error, describe what the program does with it. 10. Notes Include special comments or other information that has not already been covered.

Common Coding Practices Indentation and Code Format


A program should be concise and easy to read. It must serve as a set of computer instructions, but also as a reference work describing the algorithms and data used inside it. Everything should be documented with comments. Comments serve two purposes. First, they tell the programmer to follow the code, and second, they help the programmer remember what he did. Class discussion: Create a style sheet for class assignments. Discuss what comments should go into the programs and why.

Elements of a Program
If you are going to construct a building, the first two things you need are: the bricks and a blueprint that tells you how to put them together. In computer programming, you need two things: data (variables) and instructions (code or functions). Variables are the basic building blocks of a program. Instructions tell the computer what to do with the variables. In construction, before we can start, we must order our materials: "We need 500 large bricks, 80 halfsize bricks, and 4 flagstones." Similarly, in C, we must declare our variables before we can use them. We must name each one of our "bricks" and tell C what type of brick to use. After our variables are defined, we can begin to use them. In construction, the basic structure is a room. By combining many rooms, we form a building. In C, the basic structure is a function. Functions can be combined to form a program. An apprentice builder does not start out building the Empire State Building, but rather starts on a one -room house. Similarly a novice programmer will concentrate on constructing simple one-function programs.

Das könnte Ihnen auch gefallen