Roles of variables and elementary patterns

At the ori­gin of this les­son is the con­cept of a “pro­gram­ming plan”, intro­du­ced by Soloway and Ehrlich in 1984. A pro­gram­ming plan is a snip­pet of code that repre­sen­ts a “ste­reo­ty­pe” solu­tion to a small pro­blem. An expe­rien­ced pro­gram­mer adap­ts and com­bi­nes the­se “pro­gram­ming plans” into com­plex programs.

More recen­tly, this con­cept has given rise to two tools that can be used in tea­ching pro­gram­ming: the role of varia­bles and ele­men­ta­ry patterns.

For the con­cept of the role of varia­bles, I sug­ge­st two articles:

Choose one! As an intro­duc­tion, they are essen­tial­ly equi­va­lent. The fir­st one is from the Sajaniemi group, which pio­nee­red the area for the impe­ra­ti­ve para­digm and here extends the discus­sion to the func­tio­na­l/o­b­ject-orien­ted para­digms. The second is from the Sorva group and reports some data on the use of this approach in two uni­ver­si­ty cour­ses. I’m curious to see how you split over the arti­cles and the opi­nions that form.

On the micro­pat­tern front, the lite­ra­tu­re is less sati­sfy­ing. Just take a quick look at the fol­lo­wing article:

Discussion / Reasoning Points

  • Try to reflect on the pros and cons, in your opi­nion, of tea­ching varia­ble roles/elementary patterns.
  • Try to think about pos­si­ble approa­ches to use when intro­du­cing varia­ble roles/patterns to students.

Practical exercises

  • For tho­se with exten­si­ve pro­gram­ming expe­rien­ce, try wri­ting small snip­pe­ts of code that uti­li­ze each of the roles of varia­bles. For tho­se with less expe­rien­ce, refer to this web­pa­ge, which is part of the Roles of Variables Home Page.
  • Try to do a simi­lar exer­ci­se regar­ding ele­men­ta­ry pat­terns. There is a dedi­ca­ted web page for Elementary Patterns, but it doe­sn’t pro­vi­de an orga­ni­zed over­view of the area and is no lon­ger main­tai­ned, with seve­ral bro­ken links (1). The only pages that are still avai­la­ble are the following:
  • A much more com­plex exer­ci­se is to dust off the mate­rials from your fir­st pro­gram­ming cour­se and try to iden­ti­fy roles and pat­terns. In case they are not pre­sent, try to think about how to modi­fy the slides/notes to inclu­de them.

Material for future readings

Tracing back to the ori­gins of this line of research, cer­tain­ly the arti­cles by Soloway, Ehrlich, and Bonar are among the most inte­re­sting. Unfortunately, the pre­sen­ta­tion of their ideas is frag­men­ted across various arti­cles, which, being writ­ten in the ’80s, are also dif­fi­cult to read – both due to the out­da­ted con­struc­ts used and the fact that some are still writ­ten with a typew­ri­ter! An inte­re­sting exer­ci­se would be to read them, sum­ma­ri­ze them, and upda­te them, fol­lo­wing a more modern approach.

The Sajaniemi group has writ­ten a lar­ge num­ber of arti­cles on the topic of varia­ble roles. Perhaps too many, in my opi­nion. It would be use­ful to have a sur­vey that sum­ma­ri­zes eve­ry­thing. Here, I pro­po­se only a few of them. For a more com­pre­hen­si­ve list, take a look at Sajaniemi’s DBLP page bet­ween 2002 and 2006.

Notes

(1) For someo­ne of my age, HTML sty­le takes you back in time; for the record, one of my pro­fes­sors kept his ori­gi­nal 1994 web­pa­ge (when I was a stu­dent) until 2015. When he chan­ged it, an era ended for me.

(2) However, if you fol­low some of the pat­terns sug­ge­sted in the arti­cle on loop pat­terns, you will be cha­sed by Roberto Sebastiani with an axe.

Scroll to top