Java hamster model

from Wikipedia, the free encyclopedia
Screenshot of the Java hamster simulator
Java hamster display on a console basis

The Java hamster model is one of the mini-languages . The aim of the model is to make it easier for beginners to learn basic programming concepts through the use of playful means.

The model is based on the Java programming language , but is fundamentally independent of the language. With a minimal set of commands hamster programs should be written that steer a virtual hamster through a landscape and let him solve tasks. The basis of the model is the step-by-step process that introduces programming concepts based on one another and demonstrates them with numerous examples.

A special development environment, the so-called hamster simulator, helps with the development and visualizes the process of the self-written hamster programs. It was deliberately based on known development environments for Java and is available free of charge.

Imperative programming

In the first part of the model, all essential concepts of imperative programming are motivated and introduced step by step, in particular instructions, control structures, procedures, functions, types, variables, expressions, parameters, recursion and program design.

With some basic commands like linksUm()and nimm()and queries like vornFrei(), kornDa()or maulLeer()you control the hamster in a given landscape. The user learns to put together procedures from these basic elements that allow more complex commands.

Command overview

Commands description Type
in front() The hamster continues exactly 1 space. void
leftUm () The hamster turns 90 ° to the left. void
take() The hamster picks up a grain. void
give () The hamster lays down a grain. void
Test command description Type
front free () Returns TRUE if the hamster is not in front of a wall. boolean
kornDa () Returns TRUE, if the field on which the hamster is currently standing contains at least one grain. boolean
maulLeer () Returns TRUE if the hamster has no grain in its mouth. boolean

object oriented programing

To explain the concept of object-oriented programming , several hamsters can now be created. The normal hamster class can be expanded through inheritance .

Finally, the users learn how to teach the hamsters to play chess or reverse games. The aim is to show how the concepts presented above can be applied to complex problems.

Parallel programming

While the hamsters are explicitly controlled by the programmer in object-oriented programming , in parallel programming they form independent units that cooperate in solving tasks and have to coordinate and synchronize each other. The hamster class, from which hamsters are created, is derived from the thread class , so that all the properties and functions of thread programming can be used in parallel programming with the Java hamster model.

See also

literature

  • Dietrich Boles: Learning to program by playing with the Java hamster model . 5th edition. Springer Vieweg, 2013, ISBN 978-3-8348-0640-6 .
  • Dietrich Boles, Cornelia Boles: Object-oriented programming learned through play with the Java hamster model . 3. Edition. Springer Vieweg, 2014, ISBN 978-3-658-04802-0 .
  • Dietrich Boles: Learning parallel programming with ease using the Java hamster model. Programming with Java threads . Vieweg + Teubner, 2008, ISBN 978-3-8351-0229-3 .

Web links