Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

teaching-to-program-2019.html 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. <!DOCTYPE html>
  2. <html>
  3. <meta charset="utf-8">
  4. <head>
  5. <style>
  6. #header
  7. {
  8. background: #2BA6E3;
  9. padding: 0.7em;
  10. text-align: left;
  11. }
  12. #header a
  13. {
  14. color: white;
  15. text-decoration: none;
  16. padding: 0.5em 1em 0.5em 1em;
  17. }
  18. #lang
  19. {
  20. float: right;
  21. }
  22. .news_item
  23. {
  24. background: #FFFFFF;
  25. width: 720px;
  26. padding: 1em;
  27. margin-top: 2em;
  28. margin-bottom: 2em;
  29. border: 1px solid #E0E0E0;
  30. text-align: left;
  31. }
  32. .news_item_contents
  33. {
  34. color: #444;
  35. line-height: 1.5em;
  36. }
  37. .news_item_date
  38. {
  39. margin-bottom: 2em;
  40. color: #aaa;
  41. }
  42. html
  43. {
  44. font-family: sans-serif;
  45. }
  46. body
  47. {
  48. background: #FAFAFA;
  49. }
  50. code, pre
  51. {
  52. font-family: monospace, serif;
  53. font-size: 1em;
  54. color: #7f0a0c;
  55. }
  56. img
  57. {
  58. width: 720px;
  59. }
  60. a
  61. {
  62. color: #3A91CB;
  63. }
  64. table
  65. {
  66. border-collapse: collapse;
  67. }
  68. table, th, td
  69. {
  70. border: 1px solid #aaa;
  71. padding: 0.5em;
  72. margin-top: 0.5em;
  73. margin-bottom: 0.5em;
  74. }
  75. </style>
  76. </head>
  77. <body>
  78. <div id="header">
  79. <strong id="title">Open Game Studio</strong>
  80. <a href="../../en/news/index.html">News</a>
  81. <a href="../../en/game/index.html">Games</a>
  82. <a href="../../en/tool/index.html">Tools</a>
  83. <a href="../../en/page/about.html">About</a>
  84. <div id="lang">
  85. <a href="../../en/news/teaching-to-program-2019.html">EN</a>
  86. <a href="../../ru/news/teaching-to-program-2019.html">RU</a>
  87. </div>
  88. </div>
  89. <center>
  90. <h1>In the news...</h1>
  91. <div class="news_item">
  92. <h2 class="news_item_title">
  93. <a href="teaching-to-program-2019.html">Teaching folks to program 2019, a.k.a. in the search of an ideal program: Sequence</a>
  94. </h2>
  95. <p class="news_item_date">
  96. 2020-02-12 00:00
  97. </p>
  98. <div class="news_item_contents">
  99. <p><img src="../../images/2020-02-11_teaching-to-program-2019_screenshot.png" alt="MUROM" /></p>
  100. <p>In this article Michael shares his thoughts on teaching folks to program in 2019.</p>
  101. <p><strong>Preface</strong></p>
  102. <p>Autumn 2019 was the third time I participated as one of the teachers in the course to teach 10-15-year-old folks to program. The course took place from mid. September to mid. December. Each Saturday, we were studying from 10 AM to 12 PM. More details about the structure of each class and the game itself can be found in <a href="teaching-kids-to-program.html">the 2018 article</a>.</p>
  103. <p>I have the following goals for conducting such courses:</p>
  104. <ul>
  105. <li>create a convenient tool to allow the creation of simple games, the tool interested folks of 10 years old or older can master;</li>
  106. <li>create a program to teach programming, the program interested folks of 10 years old or older can use themselves to create simple games.</li>
  107. </ul>
  108. <p><strong>Game</strong></p>
  109. <p><img src="../../images/2020-02-11_teaching-to-program-2019_game.png" alt="Game" /></p>
  110. <p>Memory is a simple game we create during the course. The goal of Memory is to find matching items on a playing field. More details, including game mechanics, can be found in <a href="teaching-kids-to-program.html">the 2018 article</a>. You can play the created game in a web browser by clicking <a href="http://kornerr.ru/ekids2019">this link</a>.</p>
  111. <p><strong>Tool</strong></p>
  112. <p><img src="../../images/2020-02-11_teaching-to-program-2019_ide.png" alt="IDE" /></p>
  113. <p>When I was creating the tool, my guiding principle was <strong>unpretentiousness</strong> that manifests itself in the following:</p>
  114. <ol>
  115. <li>work under any operating system<ul>
  116. <li>development can be conducted under Linux, macOS, or Windows</li>
  117. <li>one can play the game on a PC, a tablet, or a smartphone</li></ul></li>
  118. <li>no need to configure anything: just open the link in a web browser and start working</li>
  119. <li>no need for the Internet: work locally if you want, there's no back-end</li>
  120. <li>the game is available to everyone<ul>
  121. <li>if you place a file on GitHub Pages, just share the link</li>
  122. <li>if you send the file over Skype, just open the file locally</li></ul></li>
  123. </ol>
  124. <p>The tool is an integrated development environment (IDE) that is technically a single HTML file. This single file contains both IDE and a project under development (Memory game in our case). The tool looks pretty standard:</p>
  125. <ol>
  126. <li>left area depicts the code of a selected module;</li>
  127. <li>middle area contains buttons to restart, save the project and manage modules;</li>
  128. <li>top right area contains result;</li>
  129. <li>bottom right area lists modules belonging to both IDE and the project.</li>
  130. </ol>
  131. <p>Since we only have a single HTML file, we should be able to run it in two modes:</p>
  132. <ol>
  133. <li>replay<ul>
  134. <li>default mode;</li>
  135. <li>just open the file;</li></ul></li>
  136. <li>editing<ul>
  137. <li>append <code>?0</code> symbols in the address bar.</li></ul></li>
  138. </ol>
  139. <p>Web browser cache (IndexedDB) is used to keep changes temporarily. To save changes permanently, one has to download the file with the changes by clicking the corresponding button in the middle area.</p>
  140. <p><strong>The first classes</strong></p>
  141. <p>I prepared <a href="http://kornerr.ru/ekids19?техника">80 lines of JavaScript code</a> for the first class and printed the code on paper. Each student received the paper and had to type the code into the tool. The typing exercise had the following goals:</p>
  142. <ol>
  143. <li>find out the typing speed of students;</li>
  144. <li>demonstrate API of the tool.</li>
  145. </ol>
  146. <p>The typing speed turned out to be extremely low: ranging from 14 symbols per minute (a student managed to type only half of the code) to 39 symbols per minute. Since I used to type the code with the speed of 213 symbols per minute, I was shocked by the results and started to doubt we would be able to write the game in an hour by the end of the course.</p>
  147. <p>We spent the second class to find typos in the code. I met typos that I have never seen in my life. I was shocked again: students had a hard time finding the typos even with the correct code on the paper in front of them. It's hard to imagine what would happen to the students' psyche if we were to pass a <a href="https://cantunsee.space/">brutal UX/UI test</a> with questions like this:</p>
  148. <p><img src="../../images/2020-02-11_teaching-to-program-2019_cant-unsee.jpg" alt="Can't unsee" /></p>
  149. <p>Later I tried to decrease the code down to 10 lines, offered partially completed code so that students could find and fix errors. Nothing helped: students just couldn't comprehend anything as if they saw hieroglyphs instead of familiar letters.</p>
  150. <p><strong>Successful seventh class</strong></p>
  151. <p>The half of the course was over, and I haven't moved an inch. In another attempt to find a way to explain the code I rewrote the game one more time. Now with a module of an intriguing title <code>последовательность</code> (<code>sequence</code> in Russian).
  152. To my surprise, the class had a stunning success: we got everything done before "the bell rang", and the students were burning with enthusiasm. The burning was so strong that we finished the class with a spontaneous brainstorm session where we came up with functionality to make the newly appeared game even better:</p>
  153. <p><img src="../../images/2020-02-11_teaching-to-program-2019_brainstorm.jpg" alt="Brainstorm" /></p>
  154. <p>The lines in Russian read:</p>
  155. <ul>
  156. <li>timer;</li>
  157. <li>tutorial;</li>
  158. <li>sounds;</li>
  159. <li>the camera should be farther;</li>
  160. <li>randomize;</li>
  161. <li>hearts (meaning lives);</li>
  162. <li>randomize after a failed matching attempt;</li>
  163. <li>exploding spheres;</li>
  164. <li>levels with different number of spheres;</li>
  165. <li>background.</li>
  166. </ul>
  167. <p>Let's look closer into the class.</p>
  168. <p><strong>Board</strong></p>
  169. <p>Previous classes were using "teachers work with each student individually" approach. After six classes we (two teachers) realized that diving into each student's specific typos/errors takes more time than teaching anything new.</p>
  170. <p>Starting with the seventh class, we decided to hook everyone to the board, i.e., the board became a central place where all of us were working, a place for everyone to stand up, approach the board and write there. PCs became secondary, a place for students to copy the board contents to. This practice clearly indicated school boards exist for many reasons:</p>
  171. <ul>
  172. <li>every student is accustomed to receiving information from the board; students know what to observe;</li>
  173. <li>teacher's environment is at the board; it's now possible to explain single new item to everyone without diving into individual errors;</li>
  174. <li>fixing individual errors becomes faster because most of them stem from negligence, i.e., typos made while copying the board contents.</li>
  175. </ul>
  176. <p>I'd like to highlight the fact that teachers work at the board together with students: a teacher sets direction; however, students stand up and come to the board themselves, write answers to the teacher's questions themselves. The benefits of such an approach are the following:</p>
  177. <ul>
  178. <li>students write with their own hands, i.e., they come up with a solution and implement it themselves, a teacher does not write for them;</li>
  179. <li>students stand up and come to the board, i.e., they move, which is good for health and drains unbridled energy that usually hampers discipline;</li>
  180. <li>students have to remember the code to copy it to the board;</li>
  181. <li>teachers have an opportunity to evaluate students' observation skills by seeing how easy (or hard) it is for them to remember and write the code on the board.</li>
  182. </ul>
  183. <p><strong>Sequence</strong></p>
  184. <p><code>последовательность</code> module of the game looks like this:</p>
  185. <p><img src="../../images/2020-02-11_teaching-to-program-2019_sequence.png" alt="Sequence" /></p>
  186. <p>The sequence allows to write an algorithm in the form of events and reactions:</p>
  187. <ul>
  188. <li>events (<code>начало</code> (<code>start</code>), <code>выбор</code> (<code>selection</code>), etc.) are lines without indentation;</li>
  189. <li>reactions (<code>настроить ThreeJS</code> (<code>configure ThreeJS</code>), <code>показать заставку</code> (<code>show splash screen</code>), etc.) are lines with indentation to signify their relation to events.</li>
  190. </ul>
  191. <p>Thus, when starting the game (<code>начало</code> event) we configure ThreeJS (<code>настроить ThreeJS</code> reaction), show splash screen (<code>показать заставку</code> reaction), and so on.
  192. The class had almost an empty <code>последовательность</code> module in the beginning; only events were present:</p>
  193. <p><img src="../../images/2020-02-11_teaching-to-program-2019_events.png" alt="Events" /></p>
  194. <p>I have duplicated these same events onto the board, leaving free space to add reactions later during the class (I used GIMP to depict free space in the following image):</p>
  195. <p><img src="../../images/2020-02-11_teaching-to-program-2019_board-events.jpg" alt="Board events" /></p>
  196. <p>We were searching for reactions in <code>память.реакции</code> module (<code>memory.reactions</code>):</p>
  197. <p><img src="../../images/2020-02-11_teaching-to-program-2019_reactions.png" alt="Reactions" /></p>
  198. <p>Each reaction of <code>последовательность</code> module is represented in <code>память.реакции</code> module by <a href="https://javascript.info/constructor-new">constructor functions</a>. For example, <code>проверить окончание</code> reaction (<code>check for ending</code>) has a uniquely corresponding <code>ПроверитьОкончание</code> function (<code>CheckForEnding</code>):</p>
  199. <pre><code class="javascript language-javascript">function ПроверитьОкончание(мир) // 1.
  200. {
  201. мир.состояние["скрыто сфер"] = 0; // 2.
  202. this.исполнить = function() // 3.
  203. {
  204. мир.состояние["скрыто сфер"] += 2; // 4.
  205. var скрыто = мир.состояние["скрыто сфер"]; // 5.
  206. var сфер = мир.состояние["сферы"].length; // 6.
  207. if (сфер == скрыто) // 7.
  208. {
  209. мир.события["конец"].уведомить(); // 8.
  210. }
  211. };
  212. }
  213. </code></pre>
  214. <p>The same code in English would look like this:</p>
  215. <pre><code class="js language-js">function CheckForEnding(world) // 1.
  216. {
  217. world.state["spheres hidden"] = 0; // 2.
  218. this.run = function() // 3.
  219. {
  220. world.state["spheres hidden"] += 2; // 4.
  221. var hidden = world.state["spheres hidden"]; // 5.
  222. var spheres = world.state["spheres"].length; // 6.
  223. if (spheres == hidden) // 7.
  224. {
  225. world.events["ending"].report(); // 8.
  226. }
  227. };
  228. }
  229. </code></pre>
  230. <p>Let's look closer:</p>
  231. <ol>
  232. <li>The function accepts <code>world</code> (dictionary) that is used by functions to communicate with each other. <code>world</code> consists of three regions (dictionary keys):<ul>
  233. <li><code>state</code> contains variable data used for communication;</li>
  234. <li><code>settings</code> contain constants to configure functions;</li>
  235. <li><code>events</code> contain <a href="https://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern">publishers</a> to be able to subscribe functions to events.</li></ul></li>
  236. <li>An instance of this constructor function is created with <code>new</code> operator while parsing <code>последовательность</code> module. Practically, everything outside of <code>run</code> method is considered to be part of the constructor body. In our case, we create <code>spheres hidden</code> variable to count hidden spheres.</li>
  237. <li><code>run</code> method is executed each time an event is reported.</li>
  238. <li>Since <code>check for ending</code> reaction is executed each time a user hides a pair of spheres, we increase <code>spheres hidden</code> counter by <code>2</code>.</li>
  239. <li>Just a shorter alias for <code>spheres hidden</code> counter.</li>
  240. <li>Count the number of spheres at the playing field.</li>
  241. <li>Compare the number of spheres at the playing field with the number of hidden spheres.</li>
  242. <li>Report <code>ending</code> event if they are equal, i.e., if all spheres were hidden.</li>
  243. </ol>
  244. <p>Students took turns searching for functions in <code>память.реакции</code> module:</p>
  245. <ul>
  246. <li>a student looks for a function in the module (to simplify the process, I've split the functions with <code>// // // //</code> symbols);</li>
  247. <li>once a function is located, the student speaks the name of the function out loud and comes to the board;</li>
  248. <li>the student writes the name down on the board to the list of found functions (students may use any means to remember the names except teacher's hints).</li>
  249. </ul>
  250. <p>Such an exercise also highlights who's actively tracking the functions and who's unable to find the next function when it's their turn.</p>
  251. <p>Once the names of all functions have been written on the board, we were mapping reactions (functions) to events in a similar fashion:</p>
  252. <ul>
  253. <li>a teacher asks, for example, which of the listed functions is suitable for event <code>начало</code></li>
  254. <li>if a student answers correctly, the student<ul>
  255. <li>comes to the board</li>
  256. <li>writes the reaction under the related event</li>
  257. <li>crosses corresponding function out of the listed functions</li></ul></li>
  258. </ul>
  259. <p>Once we have a more-or-less working set of reactions for an event it's time to transfer them from the board to student PCs. That way we managed to fill the board with reactions both on the board:</p>
  260. <p><img src="../../images/2020-02-11_teaching-to-program-2019_board-sequence.jpg" alt="Board sequence" />
  261. <img src="../../images/2020-02-11_teaching-to-program-2019_board-functions.jpg" alt="Board functions" /></p>
  262. <p>and in the tool:</p>
  263. <p><img src="../../images/2020-02-11_teaching-to-program-2019_sequence.png" alt="Sequence" /></p>
  264. <p><strong>The following classes</strong></p>
  265. <p>During the following classes, we were trying to create a new reaction and a corresponding constructor function. First, I tried to put a solution into heads quickly (providing complete lines of code); however, that didn't work. That's why we ended up with learning the following code, which took us several classes:</p>
  266. <pre><code class="js language-js">var кот = "9";
  267. console.log(кот);
  268. </code></pre>
  269. <p>Unfortunately, these two lines of code were hard to explain: students were confused with the concept of variables and their values. This wasn't the only problem: the new function required the use of an array, which I failed to explain at all. There's a long road ahead of me before I'm able to explain variables and arrays to students.</p>
  270. <p>Of course, by the end of the course we managed to complete the new function, however, I haven't seen understanding and subsequent faith in themselves, which usually manifests itself with a burning enthusiasm we saw in the seventh class.</p>
  271. <p><strong>The last class</strong></p>
  272. <p>The last class was not using the famous greeting circle at the beginning. Instead, I asked everyone (including myself) to tell what was good (+) and what was bad (-) during the course. Here's the table I got:</p>
  273. <p><img src="../../images/2020-02-11_teaching-to-program-2019_retro.jpg" alt="Retro" /></p>
  274. <p>The same table in English would look like this:</p>
  275. <table>
  276. <thead>
  277. <tr>
  278. <th>№</th>
  279. <th>+</th>
  280. <th>-</th>
  281. </tr>
  282. </thead>
  283. <tbody>
  284. <tr>
  285. <td>1</td>
  286. <td>Personalized ending screen</td>
  287. <td>Touchpad?</td>
  288. </tr>
  289. <tr>
  290. <td>2</td>
  291. <td>Working on PC</td>
  292. <td>Writing on the board</td>
  293. </tr>
  294. <tr>
  295. <td>3</td>
  296. <td>Explanation</td>
  297. <td>Discipline</td>
  298. </tr>
  299. <tr>
  300. <td>4</td>
  301. <td>Flexible learning program</td>
  302. <td>Sometimes unclear and uninteresting</td>
  303. </tr>
  304. <tr>
  305. <td>5</td>
  306. <td>There's a finished game</td>
  307. <td>Learning program is too big</td>
  308. </tr>
  309. <tr>
  310. <td>6</td>
  311. <td>A detailed explanation of algorithms</td>
  312. <td>Doing the same thing each time</td>
  313. </tr>
  314. <tr>
  315. <td>7</td>
  316. <td>Teamwork</td>
  317. <td>Students of disparate skill level</td>
  318. </tr>
  319. <tr>
  320. <td>8</td>
  321. <td>Interesting / Difficult</td>
  322. <td>Too early</td>
  323. </tr>
  324. <tr>
  325. <td>9</td>
  326. <td>Sequence</td>
  327. <td>Half of the course</td>
  328. </tr>
  329. </tbody>
  330. </table>
  331. <p>Surprisingly enough, the folks didn't like to write on the board even though it greatly increased the efficiency of teaching. On the one hand, the "learning program was too big", on the other hand, we were "doing the same thing each time", i.e. repeating what we have learned before.</p>
  332. <p>We were saving the game to GitHub from time to time. This was difficult, too: we were spending half an hour while students were authenticating. As always, nobody remembered their passwords (each time), others had to verify it's really them accessing GitHub account on a new device, which required access to e-mail, which sometimes belonged to parents (the folks had to call their parents).</p>
  333. <p>Nonetheless, each student had its own version of the game by the end of the course with personalized beginning and ending screens:</p>
  334. <p><img src="../../images/2020-02-11_teaching-to-program-2019_addr.jpg" alt="Addr" /></p>
  335. <p><strong>Conclusion</strong></p>
  336. <p>On the one hand, we had significant success:</p>
  337. <ul>
  338. <li>the tool worked as unpretentiously as expected;</li>
  339. <li>the concept of sequences was easily understood.</li>
  340. </ul>
  341. <p>On the other hand, we had an evident failure:</p>
  342. <ul>
  343. <li>the tool wasn't friendly to students without JavaScript knowledge, i.e., everyone;</li>
  344. <li>the teaching program has been stuck most of the time.</li>
  345. </ul>
  346. <p>That's why I'll try to answer the following questions when teaching in 2020:</p>
  347. <ol>
  348. <li>Will another language (Python, Lua) be simpler to explain and work with?</li>
  349. <li>Is it possible to hide Git inside the tool so that one could save the game to <a href="https://isomorphic-git.org/">Git without leaving the tool</a>?</li>
  350. <li>Is it possible to create API as declarative as <a href="https://www.hackingwithswift.com/quick-start/swiftui/what-is-swiftui">SwiftUI</a>?</li>
  351. <li>How to explain variables and arrays?</li>
  352. </ol>
  353. <p>I'll share answers to these and other questions next year ;)</p>
  354. <p><img src="../../images/2020-02-11_teaching-to-program-2019_group.jpg" alt="Group" /></p>
  355. </div>
  356. </div>
  357. <div id="footer">
  358. The site has been generated by <a href="http://opengamestudio.org/pskov">PSKOV</a>
  359. from <a href="http://github.com/ogstudio/site-opengamestudio">this source code</a>.
  360. The site is hosted by <a href="https://pages.github.com">GitHub Pages</a>.
  361. </div>
  362. </center>
  363. </body>
  364. </html>