Scratch is familiar to many people - a children's programming environment, learning in which usually comes down to creating creative projects on the principle “from simple to complex”. In this case, the “classical approach” to the study of programming (variables → branching → cycles → functions → structures → objects → ...) in Scratch is difficult.
However, changing the sequence of studying concepts (let's call them concepts) of structural, object-oriented and event-oriented programming, hiding them behind bright sprites and interactive animation, does not mean that concepts should not be emphasized. Especially if the goal is not so much the development of creative abilities, as learning programming.
I tried to reflect this idea in my
course .
')
The first thing that a beginner scratcher encounters are sprites. Although there is no object-oriented programming as such in Scratch, sprites can be considered objects. At this stage, the student sees that the program can have many objects, the behavior of which is controlled by external scripts. Sprites receive commands or, upon request, transmit information about their state, that is, programming is reduced to managing objects.
The second thing that Scratch immediately falls on the head of a young programmer is the concept of multithreading. Each sprite can have several scripts executed simultaneously. Several sprites can also execute their programs simultaneously with each other. Moreover, it turns out to be more difficult to organize sequential execution.
Already in the first lesson, we can not avoid familiarity with the cycles. Otherwise, the cat does not particularly scatter. At this stage, the acquaintance has to be left intuitive and superficial. We limit it to “repeat always” and “repeat ... times” cycles, which are easier to understand. The conditional cycle is studied in a lesson specifically devoted to cycles. This lesson assumes knowledge of logical expressions and variables.
Since Scratch is an event-oriented environment, it is more convenient to examine the blocks of the conditional operator before variables. The condition may be these or other events.
In my opinion, such a sequence is better, since for each lesson we introduce a minimum of concepts. And not abstract, but immediately see their practical use.
If, however, we first study the variables, then their purpose and benefit is difficult to demonstrate, since the conditional operator, data entry, and the generation of random numbers have not been studied before.
In Scratch, aside from lists, a programmer faces three types of data: numbers, strings, and a boolean type. The type is bound to a value, not a variable. Converting strings to numbers and back is not required. Quoted strings are not enclosed.
A block that returns a logical value and having a characteristic angular shape can be inserted into rounded fields. The reverse is not true: where a logical expression is assumed, you cannot insert a regular variable.
Scratch is implemented in such a way that no critical errors occur during the execution. Apparently, therefore, if you try to use a string in an arithmetic operation, it is replaced by zero (see the first screen).
The programmer must know that the possibilities of programming languages ​​are extended by libraries. Working in Scratch, the student can add ons that lead to the appearance of new teams in the environment.
The functions in Scratch are implemented in the “Other blocks” section, where on the one hand you create your own block that can be inserted into other scripts. On the other hand, we must collect the functionality of this block, that is, what it will do.
The return value from the scratch function is not.
Thus, the study of programming concepts in an event-oriented environment leaves its mark. In fact, we first study more complex and abstract concepts and, only delving into the process, we proceed to the elements of structured programming. Plus it or a minus for the first acquaintance - a moot point.