-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathcomposition.html
69 lines (57 loc) · 3.41 KB
/
composition.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<html>
<head>
<title>Composition</title>
<link href="61a_about.css" rel="stylesheet" type="text/css">
</head>
<body>
<h2 class="header">Composition</h2>
<p>The ease by which other <i>people</i> can read and understand a program
(often called "readability" in software engineering) is perhaps the most
important quality of a program. Readable programs are used and extended by
others, sometimes for decades. For this reason, we often repeat in 61A that
programs are written to be read by humans, and only incidentally to be
interpreted by computers.
<p>This semester, we are introducing a new feature to 61A: <b>composition
feedback</b>. A program is composed well if it is concise, well-named,
understandable, and easy to follow. The course readers are members of the
course staff in charge of making you more effective programmers. They will
review your projects and provide suggestions about how to improve the overall
composition of your programs.
<p>Readers will also assign a small composition score (around 3 points) for
each project; a few points that may encourage you to improve the readability of
your submissions. This score is for the project as a whole, not for individual
issues or questions.
<p>Excellent composition does not mean adhering strictly to prescribed style
conventions. There are many ways to program well, just as there are many
styles of effective communication. However, the following guiding principles
universally lead to better composition of programs:
<ul>
<li><b>Names</b>. To a computer, names are arbitrary symbols: "xegyawebpi"
and "foo" are just as meaningful as "tally" and "denominator". To
humans, comprehensible names aid immensely in comprehending programs. Choose
names for your functions and values that indicate their use, purpose, and
meaning. See the lecture notes section on <a
href="http://www.composingprograms.com/pages/13-defining-new-functions.html#choosing-names">choosing
names</a> for more suggestions.
<li><b>Functions</b>. Functions are our primary mechanism for abstraction,
and so each function should ideally have a single job that can be used
throughout a program. When given the choice between calling a function or
copying and pasting its body, strive to call the function and maintain
abstraction in your program. See the lecture notes section on <a
href="http://www.composingprograms.com/pages/14-designing-functions.html#designing-functions">composing
functions</a> for more suggestions.
<li><b>Purpose</b>. Each line of code in a program should have a purpose.
Statements should be removed if they no longer have any effect (perhaps
because they were useful for a previous version of the program, but are no
longer needed). Large blocks of unused code, even when turned into comments,
are confusing to readers. Feel free to keep your old implementations in a
separate file for your own use, but don't turn them in as your finished
product.
<li><b>Brevity</b>. An idea expressed in four lines of code is often clearer
than the same idea expressed in forty. You do not need to try to minimize the
length of your program, but look for opportunities to reduce the size of your
program substantially by reusing functions you have already defined.
</ul>
<p>This list may grow as we introduce new ideas in the course.
</body>
</html>