# Hello PigWorld Raymond Lister University of Technology, Sydney.

## Presentation on theme: "Hello PigWorld Raymond Lister University of Technology, Sydney."— Presentation transcript:

Hello PigWorld Raymond Lister University of Technology, Sydney

Pigworld

Boy Pigs and Girl Pigs - Note the rope

Pig Controllers

Pig Food and Food Trees

When a boy meets a girl … BeforeAfter

Class Hierarchy: Complete – 41!

Animal / Vegetable / Mineral

Model / View / Controller Views largely explain the plethora of classes Students don’t generally read them. Only one controller class, “AnimalController”

Transcending the dialectic In the procedural style, algorithms are encoded explicitly within the methods of an object, but … in the object oriented style, algorithms emerge implicitly from the interactions between objects.

Find the minimum/maximum: the one essential procedural algorithm while ( not finished ) { get next element; if ( smaller/larger than previous best ) remember this new best element; } Algorithm originally taught without reference to PigWorld, as finding the minimum / maximum of a sequence of inputted numbers. Students then adapt basic algorithm to uses within PigWorld (e.g. radar and look for food)

Note! Not banning all algorithms more sophisticated than finding minimum / maximum. More sophisticated algorithms may be implemented as interactions between objects. … for example …

Dijkstra and the “Oink” Algorithm “Oink” is Dijkstra’s shortest path algorithm. Of the students who attempted the assignment, 88% completed this task (ie. 42% of class).

By the way … Emphasize message passing between instances of the same class to reinforce basic concepts (especially class vs. object) Transmission of sound does that nicely

Rope and Linked Lists Doubly linked list. Students given code to play out rope. Assignment task was to destroy the rope of a pig. Of those who attempted the assignment, 82% completed this task (ie. 39% of class). Recursion NOT required. Done by message passing.

Once again … Emphasize message passing between instances of the same class to reinforce basic concepts (especially class vs. object) Destroying rope does that nicely

Teach Linked Lists before Arrays Teaching linked lists early reinforces: –Message passing –Objects versus classes Arrays are a distraction from the above key concepts: –Come with their own syntax

Re-use Classes (Animae)

Want to Know More? Lister, R. (2004). Teaching Java First: Experiments with a Pigs-Early Pedagogy. Sixth Australasian Computing Education Conference (ACE2004). Dunedin, New Zealand. January 18-22. pp. 177-184. In the ACM Digital Library. Email me if you’d like to have the code.

c.f. Greenfoot http://www.greenfoot.org/ …http://www.greenfoot.org/ “Consider greenfoot as a combination between a framework for creating two-dimensional grid assignments in Java and an integrated development environment (class browser, editor, compiler, execution, etc.) suitable for novice programmers.” The existing implementation of PigWorld is a little clunky; a re-implementation within Greenfoot would be ideal.

Conclusion (1): Assignment design principles Emphasize message passing between instances of the same class to reinforce basic concepts (especially class vs. object) Use only simple loops that search for smallest or largest values in a sequence. Teach linked lists before before arrays. Ideally, don’t even teach loops in semester 1 Reuse classes

Conclusion (2): Transcend the OO vs. Procedural dialectic In the procedural style, algorithms are encoded explicitly within the methods of an object, but … in the object oriented style, algorithms emerge implicitly from the interactions between objects.