2
$\begingroup$

I was looking at the CAS progression pathways, and noticed that in column 2 (Programming and development), it has selection (if) before variables.

CAS - progression pathways
https://community.computingatschool.org.uk/resources/1692/single

I realise (from talking to the author), that the colour bands and the arrows were added with protect, and should be ignored. They were added for an era that was obsessed with levels, the day before levels were abolished (for key-stages 0-3).

As a lot of teachers still teach in the order that is in this document, I was wondering: Is it possible to teach selection (if) before variables.

I am asking this, as I am creating a dependency graph, so that I know what has to be taught before what.


When I teach Python, I teach both much later, after iteration, procedures, and functions.

$\endgroup$
8
  • $\begingroup$ Actually, it seems to have understanding programs (first & second rows) prior to creation of programs (third row). I don't think it implies that there are no variables in the programs to be understood. Especially if variables at that level are just presented as references to values. A complete understanding of variables (as things that can be changed) is necessary for the goals of the first two rows. You are probably reading too much into it. $\endgroup$
    – Buffy
    Commented Dec 24, 2017 at 14:25
  • $\begingroup$ OTOH, in an OO world or a Pure Functional world, yes you can, but I don't think that is the intent of the curriculum here. $\endgroup$
    – Buffy
    Commented Dec 24, 2017 at 14:27
  • $\begingroup$ This question is related but different cseducators.stackexchange.com/q/1482/204 $\endgroup$ Commented Dec 24, 2017 at 19:02
  • $\begingroup$ If it is raining and it’s a weekday, Mary goes to the store. It is raining and it’s Saturday. Does Mary go to the store? We can teach selection in spoken language before we convert to if else in code. You could argue either way for the presence of variables in this sense. $\endgroup$
    – ThisClark
    Commented Dec 25, 2017 at 1:55
  • 1
    $\begingroup$ @TuringTux yes, It will be in a public repository. And I will try to remember to put it here. Hope I get time to work on it. $\endgroup$ Commented Dec 26, 2017 at 9:41

4 Answers 4

5
$\begingroup$

From a practical standpoint, rather than a theoretical one, there are at least two pedagogically defensible ways to do this. Spiral curriculum, and Scaffolding

Use a Spiral Approach

I won't assume that you never mention variables early with this approach, but you just don't teach all that needs to be known at the first introduction of variables (or any other topic). To teach like this you mention things that need to be known deeply early on, partly to introduce terminology, but partly to permit simple uses in which deep knowledge isn't needed. Then, for example, variables but without reassignment could be used in setting up some sort of selection or iteration as your lecture focuses on those ideas rather than the variables. At any given point in time students know a little about a few things and a lot about some other things. Then, in the next cycle you go a bit deeper in some topics but also introduce, very lightly, other topics.

The implication is that a student never needs to completely understand any given topic the first time it is presented as it will be seen again. Everything is reviewed constantly in such a course.

For purposes of this particular question, a variable could be initialized somehow and then used within a selection structure. The student need only have the idea that the variable refers to a value and can be thought of as a temporary name for that value.

Teaching a course in a spiral way requires some pre-planning, of course. It isn't enough to put each important topic into the syllabus only once. Neither is it enough to expect that every student will get a lot out of the first introduction and you don't, therefore, need to obsess that everyone is on the same page before moving to the next topic.

Use Scaffolding

An independent way of teaching is to have students first programming experiences done within a pre-defined richly endowed virtual world. The world is constructed so that interesting things can be done early without necessarily building up everything from the beginning. Often these world are simulations. For example, in Karel the Robot and its successors, programs consist first of writing sequences of statements to direct an existing robot. The robot's capabilities are built in and the student simply invokes existing functions/methods to achieve some complex effect. Next the student learns to write methods or functions as just abstractions over some sequence of such pre-build actions and other actions already built by the student. In this way it is functional abstraction that is the first real topic of importance. You can introduce variables or not, and you will certainly do so when you want several robots acting together. But these variables are just object references and little needs to be known about them, including whether they can be reassigned or not. Selection is certainly a reasonable topic in such a world, as is iteration, polymorphism, recursion, or whatever you need to teach.

However, careful thought needs to be given to the characteristics of the simulation world. How rich is the environment. It can be simple, for example, and still be Turing Complete.

Some teachers might choose this path with a single simulated virtual world, and others might choose to use several worlds of increasing sophistication and, perhaps, increasing complexity. I'll note that Greenfoot was built precisely to provide an environment in which such simulations and virtual worlds would be easy to build.


Both of these techniques are very powerful and have been used by many instructors over a long period of time. Of course, they may be combined to good effect.

$\endgroup$
4
  • 1
    $\begingroup$ Spiraling is the logical combination of how every expert ever learned their topics with good, common sense. I have no idea why more curricula aren't written this way. When I taught vocal music, I so intensively spiraled my curriculum that it became next to impossible to write formal lesson plans in the format required by my district. I got in trouble for it a number of times, but I still believe strongly that it was a better approach for the students, who thrived. $\endgroup$
    – Ben I.
    Commented Dec 24, 2017 at 20:17
  • $\begingroup$ For New Yorkers, a common question is "How do you get to Carnegie Hall?" $\endgroup$
    – Buffy
    Commented Dec 24, 2017 at 20:19
  • $\begingroup$ And the answer.... $\endgroup$
    – Buffy
    Commented Dec 24, 2017 at 20:20
  • $\begingroup$ Practice, practice, practice. $\endgroup$
    – Buffy
    Commented Dec 24, 2017 at 20:20
3
$\begingroup$

The first 6 or 8 days of the year we work in Jeroo instead of straight Java (there's a Python mode as well). It serves as a very quick introduction to syntax, ifs, and while loops. I've found it helps when I can go back later in the year with "remember in Jeroo when..."

What Jeroo doesn't have is variables. You can't do things like loop 5 times. You can only loop or if while a Jeroo hasFlower(), isFacing(EAST), or something like that.

They're not directly using variables, although they're using boolean conditions. I've found that starting with methods like hasFlower() makes the idea of x == 2 easier to wrap their heads around when we get to it.

We only spend a few days in Jeroo because students start to get frustrated with what it can't do. You can't tell a Jeroo to loop a set number of times. You can't ask a Jeroo what column or row they're at. You can't ask them how many flowers they have. Any of those frustrations work really well as a hook into why variables are useful.

$\endgroup$
4
  • $\begingroup$ That brought me down a fruitful little rabbit hole. $\endgroup$
    – Ben I.
    Commented Dec 25, 2017 at 18:11
  • $\begingroup$ I'm pretty sure that Jeroo, like Karel from which it evolved, is Turing Complete. $\endgroup$
    – Buffy
    Commented Dec 25, 2017 at 20:58
  • $\begingroup$ Have you any idea what the licence is? There is not mention on their website, or anywhere else that I can see. $\endgroup$ Commented Dec 26, 2017 at 10:35
  • $\begingroup$ Not sure on the license. Never thought to look. $\endgroup$
    – Ryan Nutt
    Commented Dec 26, 2017 at 13:45
0
$\begingroup$

This year I managed to present both functions and if-then-else before variables to my (total beginners) students. We're using Processing.

Students are first presented with basic drawing operation (rect, ellipse, fill)

Exercise for Functions : draw a moderately complex picture

Solution (sketch of):

 void setup() {
     size(600, 200);
 }

 void draw() {
    draw_sky();
    draw_seashore();
    draw_boats();
 }

Exercice for if then else : draw a square on the screen, and a circle for the mouse pointer. Circle is red when inside the square, green otherwise.

Well, mouseX and mouseY are framework variables, actually. We also constants (final), both global and local, so the students get familiar with the notion of scope. A bit later, parameters for functions (drawing the same shape at different places) are introduced. And then, "real" variables representing a user-changeable state (say, last position where a click occured).

A better example, if really dont want the coordinates variables:

void setup()
{
  size(200,200);
}

void draw() {
  background(255);
  if (second() % 2 == 0) {
    draw_square();
  }
}

void draw_square() {
  fill(0);
  rect(50, 50, 100, 100);
}

A more elaborate example is drawing a clock with three needles. Makes a strong motivation to introduce variables for auxiliary computations.

PS: some readers are not familiar with Processing and are too busy to have a look at the documentation, so :

  • the second() function returns the current second (an int between 0 and 59).
  • in a Processing program, the framework calls setup() and then loops around draw(), just like Arduino with setup+loop. Programmer has to provide the draw/setup functions together with functions as responses to events (mousePressed, etc).
  • the example shows a blinking square.
$\endgroup$
10
  • $\begingroup$ I don't understand. I nee no selection, or variables in the example. $\endgroup$ Commented Dec 27, 2017 at 15:29
  • $\begingroup$ Those are procedures, not functions. And constant variables are (real) variables. Valuables can be mutating or non-mutating (const). In a functional language, all variables are non-mutating. variable ≠ mutating. $\endgroup$ Commented Dec 27, 2017 at 15:31
  • $\begingroup$ I would be curious to see a Processing example that uses if statements without variables, but mouseX and mouseY are variables. $\endgroup$ Commented Dec 27, 2017 at 17:17
  • $\begingroup$ @ctrl-alt-delor in the Processing documentations, methods are often referred as 'functions". Example processing.org/reference/parentheses.html "Parentheses have multiple functions relating to functions and structures. They are used to contain a list of parameters passed to functions and control structures $\endgroup$ Commented Dec 27, 2017 at 20:23
  • $\begingroup$ The program you give is impossible to understand, with out a global understanding, and that is missing. This is primarily because of a poor choice of names (yours or the frameworks). E.g. size is a noun, so we would expect it to return a value, but it does not. I guess it sets the size (setSize). second is a noun so should return a second object (what ever that is), but seems to return a number, so maybe it is the second number, but of what. I see no list. For this reason it is not useful. Therefore I will down-vote. $\endgroup$ Commented Dec 29, 2017 at 10:27
0
$\begingroup$

Yes. Programming languages that don't have variables still have conditional branching. The paradigm is called "functional programming".

Here is a link to a list of programming languages that support functional programming: https://en.wikipedia.org/wiki/Category:Functional_languages

A list of pure functional languages can be seen at this link: https://en.wikipedia.org/wiki/List_of_programming_languages_by_type#Functional_languages

Here is an example functional programming exercise in javascript that I found: https://hackernoon.com/challenge-program-without-variables-javascript-bee89a41455e

Here are some other links of interest: https://stackoverflow.com/questions/1020653/how-can-you-do-anything-useful-without-mutable-state https://www.cs.ox.ac.uk/geomlab/CAS-article.pdf

$\endgroup$
1
  • $\begingroup$ So is the dependency (variables or functional)? $\endgroup$ Commented Dec 30, 2017 at 13:17

Not the answer you're looking for? Browse other questions tagged or ask your own question.