Experience in teaching schoolchildren programming

    About a year and a half ago, the company I worked for decided to start an educational project: to prepare future programmers from the student and even school bench. The decision was caused both by the lack of qualified programmers in our region, and by the fact that there are a lot of new graduates who have to graduate - the education received at the university does not fully meet the modern realities of the software development industry. The project is mutually beneficial both for students who get the opportunity to get acquainted with industrial programming in practice, and for a company that will receive qualified specialists in a few years.

    But even more interesting was the part of the project, focused on working with students. I am directly involved in this part, so I want to talk about it.

    The problem of school programming programming


    Why do you need to work with schoolchildren? It seems to me that the greatest success can be achieved by starting to teach students in grades 8-9 - in the future, learning decreases. School teachers of computer science have time to “teach the bad”, including they often discourage interest in programming, as a result, there are only those who are ready to learn “not thanks, but contrary to” - those who in any case will strive to become programmers, “techies” ". Unfortunately, those who have less thirst for this area, but are very capable, are eliminated already at this stage.

    The main problem of school programming teaching is the lack of a systematic approach to this issue. The trouble is that at school they teach not to solve problems using programming, not to develop programs, but only to the programming language as such. School lessons come down, in essence, to learning the constructions of the language and completing any tasks for these constructions, but they don’t teach a much more important skill - to use them to solve problems that arise in practice. Those students who have a talent for programming learn this on their own, the rest get the idea of ​​programming as "a boring and boring lesson for nerds."

    But programming is needed not only by the “chosen ones”. In programming lessons, children learn primarily to work with information, structure it, manage it, and these skills are vital in the face of an ever-growing “informational wall” of modern life. Even a rough understanding of how a computer is designed, how it works and executes programs, what its capabilities and limitations are, is an important skill in the current conditions, when computers have penetrated literally everywhere and more and more become some kind of magic for an ordinary person (“I’m only I pressed a button, and here it’s taco-oh-oh !!! ”). Even if the child does not become a programmer, the skills acquired during programming will be a good help for him in his future life. He’s not going anywhere from computers.

    Method I.R.Dedinsky

    The search for teaching methods that are different from modern school patterns brought us to a wonderful, enthusiastic person - Ilya Rudolfovich Dedinsky. He works as a senior teacher at the Moscow Physics and Technology Institute (MIPT) plus a teacher at the physics and mathematics school, and he achieves tremendous success with schoolchildren - his students are already writing grades 9–11 for programs in complexity corresponding to the 3-4th course of a technical university (!) - compilers, three-dimensional engines , simulate physical processes, consciously working with projects of a much larger volume than can be expected even from students. Moreover, importantly, Ilya Rudolfovich achieves such results regularly. These are not stars, these are ordinary students (though from a physical school). As he himself says, "the method must be judged by the middle peasants." "Stars" will always be lagging behind, alas - too. Level achieved by the main part of the group - this is a true indicator of the quality of the applied methodology and the teacher’s work. Examples of the achievements of his students are given on the site of Ilya Rudolfovich, in particular, this is the work of the tenth grader Ivan ShapovalovPlatform for machine-independent execution of program code with the possibility of JIT compilation and teamwork by Leonid Stolyarov (9th grade), Fedor Petryaykin (9th grade) and Nikita Uvarov (7th grade) Platform for an automated multi-agent system in the 3D-Action style .

    I happened to meet with Ilya Rudolfovich, talk to him personally, listen to the story about his methods “first hand”. Taking it as a basis, we developed our own version of his training program, based on the same principles. Unfortunately, it’s very difficult for us to use the original methodology of Ilya Rudolfovich due to the lack of pedagogical experience. It is likely that we have not yet appreciated all its advantages and opportunities, since Ilya Rudolfovich has been honing his training program for more than one year. I believe that with experience there will come an understanding of what can be improved in our program. But, as you know, a training program is not a thing that can be thoughtlessly copied, it must be understood first hand. The following are the principles that underlie our training program,I.R. website Dedinsky in the section "Basic materials" ):

    1. "Teach only the good." Children should immediately, from the first lesson, see the right, good goals and the right, good examples. If you do not pay attention to some things (for example, formatting the code), let them go by chance, the children will do it as they "understand" themselves. Subsequently, they will have to be retrained, and this is always much less productive than being taught correctly from the very beginning. Therefore, in the first lesson, children will learn how to use spaces and indents correctly, and why empty lines are important that break the program into logical fragments. From the very first lessons, the concept of the quality of names is introduced, and children are required to use friendly names for variables and functions.
    2. "Teach programming, not language." All concepts given to children are derived as a tool for solving the problem. Not even quite like this: at first the problem is formulated, it is given the opportunity to “feel” it, to try to solve it using available means (as homework or together with the teacher in the classroom). For example, we can draw a house on the screen (we already have such a function). Let's draw on the screen 5 houses one after another. The task, of course, can be solved by calling the function 5 times. But, checking the technology, we ask questions: what if 10 houses are needed? fifty? 100? And if 4? And if so, how much will fit on the screen? Or as much as the user enters the program? Then the children are invited to discuss how this problem could be solved, and usually they themselves, with some help from the teacher, formulate the idea of ​​a cycle with varying degrees of approximation. Only then is the syntax of the loop operator described in the programming language chosen for training.

    Task sequence


    The sequence of knowledge and skills acquired by children is focused on their practical use. As I wrote above, constructions are given as a result of problems encountered in children in the learning process. Of course, the tasks are selected precisely so that these problems arise in a certain order - this is one of the tasks of the teacher. Tasks are selected according to the principle: the more important the skill, the earlier it is learned. Importance is understood as the frequency of use of a construct in industrial code. That is why functions, the most important element of programming, are studied as early as possible.

    One of the problems of a modern schoolchild, even mathematically educated, is the illusion of competence in working with a computer (everyone knows how to download music or install Skype) and at the same time fear and uncertainty about programming (“it's hard, I never understand”). Therefore, to remove this fear in the first lesson, children are invited to play a business game, which at first glance has nothing to do with computers or programming 1. During the game, participants imagine themselves to be the owners of an advertising agency, to which a certain customer (teacher) comes and wants to order an advertising banner. But which one does not explain, referring to fatigue, and offers to ask him questions, from the answers to which a contract will be drawn up. Such a veiled discussion of TK. He reassures all questions about money, banner installation, installation permissions and other things: “This is not a problem. There is money, there are permissions, it’s not the first time we hang such advertisements, workers have already been called. ” The catch is that the banner is needed tomorrow , and its size is 100 by 400 meters . What will he do with him so huge?

    Why do we need a banner (monologue of a harmful customer)

    “You see, I am the owner of a major trading network,“ Teapot Unlimited. ” We sell any dishes - from collection cups of the finest porcelain to metal teapots. Just recently they sold a service to the Emirates ... for 50 million, from platinum. Now negotiations with China on large supplies of inexpensive dishes. So, I open a store in your city, and it so happened that I completely forgot about advertising. The assistant got sick, and it flew out of my head. I can’t move the opening date - everything is planned, ordered, there will be damage to the reputation ... To be honest, today your competitors had this question, we talked a lot, drank tea, everything was very nice, but ... at the last moment they said that they have some difficulties, and they won’t take the order. And I have come to you. In general, you need a banner. At least one. I'm a little tired of talking with your competitors,

    The following are the customer's answers to students' questions, a description of what needs to be depicted and how, etc. Here it comes to the drawing, size and timing. If the game takes place in Moscow, then this huge banner is proposed to stick to the wall of a skyscraper - so it will be visible from afar. In my case, for lack of a skyscraper, even in the project, I had to fantasize a balloon on which advertising would hang over the city.

    Who will do this?

    After unexpected answers about the size and timing of this, the guys have a slight shock. This is an important point: they will learn how to find out substantially all the details before starting work, even if they were not explicitly in the task. In fact, this is a game training on the compilation of TK. When this phase is completed, the teacher “rolls out the“ secret weapon ”onto the stage - it turns out that the design company has a familiar artist who can draw the required banner on time. But this artist lives in a remote wilderness, and the only way to contact him is to make a phone call. He’s a bad type, you need to talk to him accurately and accurately, otherwise he will hear a strange word a little - he will hang up and have to call again. Next is a list of phrases that you need to talk to him: set the canvas, set the color, draw a line, etc. Actually, This is how the abstract artist (“Dumb Artist”) and his team system are introduced. But not only formally, but with reference to the situation, which is perceived by students much more naturally.

    Then the children collectively “call” the “stupid artist” (the role of which is played by the teacher) and team by team manage the “artist” who performs their actions — well, or “takes offense” at a syntax error and hangs up, and then the dialogue starts again. In essence, this is the execution of the first program on pseudo-code by the executor in the interpretation mode. After 4-5 unsuccessful attempts, the program is written.

    Thus, in the first lesson, children will learn two important points: setting a task and writing the first program. The program is written on the board, and very much attention is paid to indentation, blank lines and spaces - that which is often omitted and which is so difficult to consciously teach later.

    Pseudo-code program
    Включи библиотеку (включи в свою голову знания из нее о том как рисовать)
    Главная работа
    Начало
      Установи холст 100 400
      Установи цвет красный
      Линия 25 300 75 300
      Линия 25 300 50 100
      Линия 50 100 75 300
      Установи цвет зеленый
      Окружность 65 200 40
      Установи цвет синий
      Линия 40 180 20 80
      Вернуть результат
    Конец

    The command system is selected so that the pseudo-code matches the C program as much as possible.

    C ++ Program
    #include "TXLib.h"
    int main()
    {
      txCreateWindow(100, 400);
      txSetColor(TX_RED);
      txLine(25, 300, 75, 300);
      txLine(25, 300, 50, 100);
      txLine(50, 100, 75, 300);
      txSetColor(TX_GREEN);
      txCircle(65, 200, 40);
      txSetColor(TX_BLUE);
      txLine(40, 180, 20, 80);
      return 0;
    }
    

    The TXLib.h library (TX stands for “stupid artist”) was developed by Ilya Rudolfovich and provides a simple API for drawing various drawings, running under Win32. More details can be found on his website .

    As already mentioned, when writing this program, special attention is paid to formatting - empty lines dividing the program into logical fragments, indents and spaces, which make it easy to read the program. In the future, the teacher attaches great importance to this and grumbles until the student prepares the code properly: “You ask, why does this your code not work? But who knows, you won’t understand it right away. The names are all single-letter, there are no spaces, indents are set randomly ... Make the program easy to read, then I will help you find the error. "

    Briefly about further training

    The homework after this lesson is writing a program that draws several heroes of the future cartoon. The main function immediately swells up to 50-100 lines, and some enthusiastic students have more. Therefore, in the second lesson, we introduce the concept of “function” - so far without parameters, of the form void DrawMan (), and in this way we break the program into parts. For commonly used colors, we introduce the concept of “constant” and name the constants that appear in the program in an understandable way. The emphasis is on the comprehensibility of function names and constants. In fact, this is a lesson about code grouping and naming.

    Next, we try to draw the same object in different places on the screen, in different colors, etc. We introduce the concept of “function with parameters”, add parameters to the functions written at the last step - this is a typical refactoring. The emphasis is on the comprehensibility of names, on the "flexibility" of the resulting function and on the mutual independence of its parameters.

    After that, we try to make an animation - moving objects, the simplest "cartoon". We introduce the concept of “cycle” (and here are local variables). Again, emphasis on friendly variable names, indentation in a loop. We write a cycle in which cartoon characters are drawn. Already at this stage, children begin to paint quite complex and spectacular scenes: for example, one of my students had a house painted over which the sun “flew” from sunrise to sunset, then the moon. The color of the whole picture changed depending on the position of the sun (moon) in the sky. It is not easy to describe in words, but it looked very impressive.

    When the functions become well with a lot of parameters, the concept of “structure” is introduced, and the cartoon objects are described in the form of structures. Again, emphasis is placed on the comprehensibility of the names of structures and their fields, on the logic of grouping data into structures.

    Then they discuss the possibility of using the written code repeatedly to create another cartoon with the same characters. The concept of “library” is introduced (at this stage everything is put together into one .h file, we do not introduce separate compilation, since it is very difficult for all beginners to understand). It is proposed to formalize the functions in the library, use it ourselves in the program, document it, provide examples of working with it, and let comrades use it. Comrades, having received a foreign library, they try to use it and write a review, which results in the release of a new version of the library (in fact, this is the release of the SDK and peer review).

    The development of the project turns the cartoon into a simple computer game (in our case, Arkanoid was chosen). In the process of writing a game, you have to deal with functions that change the state of their parameters, and using this, the concept of a “pointer” is introduced and the transfer of parameters by a pointer. In our case, after some time, arrays were also required. ( Important: we do not give address arithmetic here. )

    In the process of writing a game, there is a need to handle user keystrokes - a design such as “branching” appears. In principle, branching may appear earlier, but I only needed it in this place. Compare with the classic course, where if is given almost by the very first operator, and they talk about functions closer to the end, which is why they are used a little, "developing" the ability to write "pasta" code. The late appearance of if is caused by the specifics of the selected project - "cartoon", with a different sequence of training tasks, it can be entered even before the cycle. But in this project, movement (cycle) is more relevant than variability (branching) and the operation of the condition in the cycle is more visual.

    Typically, children are not told about global variables throughout the first year. On the contrary, the locality of variables and function parameters is emphasized everywhere. That "this" X "in this function and that" X "in another function are completely different, not connected in any way."

    In the future, children will learn about pointers to functions, strings, classical algorithms, and begin to get acquainted with the parsing of arithmetic expressions. But this is already a very big and long story.

    Total


    I have been studying with this student for about one academic year (since last October). Classes - 2 times a week, one lesson - 3 academic hours (120 minutes, including a ten-minute break). The group is of different ages, from 8 to 11 classes. But I can be proud of the result - the children really learned how to solve problems on their own. I am sure that my students in grades 8–9 will be able to easily attend school sections on programming in grades 10–11. The last time, when the task was given to write the program “Guess the Number” (the computer guesses, the player guesses on the principle “more-less” - binary search), everyone coped with it on their own. I just walked around and watched how the children iteratively twist the functional - almost everyone started with the main test (if for coincidence / more / less), then “wrapped” it in a loop, then started adding “decorations”. As a result, after a few comments, I got a code for which I am not ashamed. Of course, this is far from the most difficult task that students are able to solve, but this example turned out to be very indicative for me, because it made it possible to see independent work from beginning to end in one lesson.

    I can say that, in my opinion, the teaching methodology of I. R. Dedinsky, taken as a basis, is a great progress in the field of teaching children programming. It brings the base to the learning process, allows you to systematize it, interest children, show them that programming is very interesting, allows you to give children more knowledge and skills in programming than the traditional school curriculum. But I want to note that this technique makes considerable demands on the teacher. Many not always recognized nuances (for example, the teacher's choice of a too abstract name for a function or variable for the sake of reducing records, or the introduction of global variables to "simplify" the explanation of the functions) have far-reaching unpleasant consequences that need to be well understood. The teacher must have practical programming experience to clearly explain why it is necessary to do just that and not otherwise, and it is very desirable with practical examples (and not through prohibitions without explanation). He should be able to quickly understand the code of students, evaluate its condition and the consequences of its development, imagine if such a code fragment could be used in a real project. For example, a variable left uninitialized: on a training machine, it does not always lead to an error, but when changing the compiler / compiler version / OS version / moon phase it can lead to undefined program behavior. Unsuccessful variable names, style violation: why is everything here with a capital letter, and here with a small one? why is there a "camel" style, and here through underlining? —This are some of the “little things,” of which not only a functionally working one is formed, but also a clean, correct, professional code, and the teacher should pay special attention to this. Unfortunately, without practical experience, this skill is quite difficult to acquire. Practical experience is also a good argument. When explaining, I often use the example “... and you flew away on vacation to Tahiti. And here - bam, an error in your module! Colleagues are in a panic, they can’t quickly figure out your code, they urgently call you back from vacation — and here you are right in the beach shorts ”. A little exaggerated, of course, but the essence conveys. When explaining, I often use the example “... and you flew away on vacation to Tahiti. And here - bam, an error in your module! Colleagues are in a panic, they can’t quickly figure out your code, they urgently call you back from vacation — and here you are right in the beach shorts ”. A little exaggerated, of course, but the essence conveys. When explaining, I often use the example “... and you flew away on vacation to Tahiti. And here - bam, an error in your module! Colleagues are in a panic, they can’t quickly figure out your code, they urgently call you back from vacation — and here you are right in the beach shorts ”. A little exaggerated, of course, but the essence conveys.

    Of course, in this article it is impossible to tell everything. Of course, also, that this approach does not claim to be the only loyalty, because there are many ways to teach programming. If this topic is interesting to you, please ask questions in the comments, I will answer. If there are a lot of questions, the article will be continued.

    References


    Ilya Rudolfovich site
    TXLIb library TXLib
    documentation
    Presentation of Dedinsky on teaching methods (pdf)
    Dedinsky's report “An analytical approach to pre-university teaching of programming”
    Curriculums (pdf)


    1 The game "Harmful customer" and the subsequent "Call a dumb artist" are borrowed from the program of I. R. Dedinsky almost completely. ( Back to text )

    Also popular now: