Class 9 M 2/11 Comp 110 Plagarism Developing Prog 4 - Making Change Programming with style Loops Listing 4-1 Listing 4-2 Programming style There are 2 audiences for your programs Computer Human To satisfy the computer, the program must produce correct results. However, this is not enough. Your program must make sense to the human reader. Why? In software development, programs are modified, extended, and rewritten over and over again. Goal - The human reader must be able to read and understand your program. Components of good programming style The solutions to Program 4, Making Change, show many examples of these points. 1. Use descriptive names. Each name of a variable, method, or class should clearly describe its purpose. Examples: x vs. xPosition n vs. numberOfGrades (some abbreviation is acceptable, numGrades) q vs. quarters method1 vs. compute Average large vs. findLargestValue This is the most important characteristic of clearly written programs. 2. The code is clear and consise. 3. Comments are used to explain the code. You do not need a large number of comments. a) Each class must have a block of comments at the start explaining what the code does author, date, and course b) Within the Java code itself, blocks of closely related statements are prefaced by a comment explaing what the code is doing (not how it accomplishes this). This is called paragraphing - breaking your code into short sections of closely related statements. Steps in your Implementation Plan often make good paragraphs. 4. Formatting. Especially important is the indentation of your code. The physical presentation on the page must reflect the logical structure of the code itself. Eclipse will do this for you (Source/Format).