Skip to content

Commit 5eaf8a4

Browse files
committed
Starting to add code schematic content
1 parent e65a210 commit 5eaf8a4

3 files changed

Lines changed: 69 additions & 0 deletions

File tree

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "5d45e2b5-ee5e-4073-b724-6bf366dcc365",
6+
"metadata": {},
7+
"source": [
8+
"# Planning Your Code and Writing A Code Schematic\n",
9+
"\n",
10+
"Just as it is a good idea to plan an essay or report before you start writing, it is a good idea to plan your code before you sit down and start typing.\n",
11+
"\n",
12+
"In the case of an essay, planning allows you to separate thinking about *what* you want to say from *how* you are going to tell it.\n",
13+
"By creating a formal outline, you can identify exactly what points you want to make and how these will be organised to best communicate your overall idea to the reader.\n",
14+
"Once you have your outline, you can then start piecing together the words, sentences, and paragraphs that will make up your full first draft.\n",
15+
"While writing this first draft, you might realise that a particular part of your outline does not work as well as you had thought — you can modify your outline according to your new (hopefully better) idea and then return to your writing.\n",
16+
"\n",
17+
"As is the case for any moderately complex project, writing code benefits from planning. While it can be tempting to immediately start writing bits of code as you think through a problem, this can result in frustration and lost time as you get stuck in dead ends, or solve what you *thought* the problem was, rather than the real problem, or, halfway through, you realise that you do not actually know how to implement a critical step.\n",
18+
"\n",
19+
"In addition to saving you time and tears, planning your code will also help you to get better at programming. Writing a detailed code plan requires thinking through a complex problem and identifying how to deconstruct it into a sequence of well-defined, smaller, simpler problems that you know how to solve. This skill allows programmers to work on highly complex problems, as they are able to break them apart into small sub-problems that can be solved and then recombined.\n",
20+
"\n",
21+
"Like planning for any project, there are lots of possible ways to approach planning your code. In this course, we will cover an approach we call a “code schematic” — this is a document that is analogous to a detailed outline of an essay. Once written, a good detailed outline could be given to a second writer, and, providing they are reasonably competent, they could then produce an essay that makes the intended argument, even if the phrasing and writing style might be different. Similarly, a code schematic could be considered “good” if it could be given to a second programmer, who could then produce a code implementation that solves the original problem.\n",
22+
"\n",
23+
"A code schematic breaks a coding problem into a sequence of smaller steps and defines how these should be combined or linked. Because computers cannot think for themselves, a clear code schematic should include enough detail and specificity that there is no ambiguity about what each step of the code should do or how it should be done.\n",
24+
"\n",
25+
"We can illustrate this idea with the example of a relatively simple non-computational task — making tea.\n",
26+
"\n",
27+
"Here is a simple “code schematic” that attempts to solve this problem:\n",
28+
"\n",
29+
"1. Put the tea bags in the mugs\n",
30+
"2. Boil the kettle\n",
31+
"3. Pour the water into the mugs\n",
32+
"4. Let the tea brew\n",
33+
"5. Take the tea bags out\n",
34+
"6. Serve the tea.\n",
35+
"\n",
36+
"We could also present this as a flow-chart:"
37+
]
38+
},
39+
{
40+
"cell_type": "code",
41+
"execution_count": null,
42+
"id": "1b635573-9b6a-443b-833f-b2d3ed5ad057",
43+
"metadata": {},
44+
"outputs": [],
45+
"source": []
46+
}
47+
],
48+
"metadata": {
49+
"kernelspec": {
50+
"display_name": "Python 3 (ipykernel)",
51+
"language": "python",
52+
"name": "python3"
53+
},
54+
"language_info": {
55+
"codemirror_mode": {
56+
"name": "ipython",
57+
"version": 3
58+
},
59+
"file_extension": ".py",
60+
"mimetype": "text/x-python",
61+
"name": "python",
62+
"nbconvert_exporter": "python",
63+
"pygments_lexer": "ipython3",
64+
"version": "3.11.10"
65+
}
66+
},
67+
"nbformat": 4,
68+
"nbformat_minor": 5
69+
}
358 KB
Binary file not shown.
26.7 KB
Loading

0 commit comments

Comments
 (0)