next up previous print clean
Next: Why Java? Up: Why object orientation? Previous: Why object orientation?

Notes and Comments

Axelrod organized a fascinating programmer competition as the basis of his book . Every participant had to submit a program that would face off withanother program in a prisoner-dilemma situation. Axelroth carried out a tournament between player strategies submitted in form of a program by fellow game theoreticians. Such a tournament is easily organized in a object oriented language: As an exercise, design an abstract player class. Make sure every player shares the same accounting methods. Implement two players for that abstract player class. Axelroth limited his competition to duels. Assume you interact within a community of up-to 100 individuals. You have to add a getName() to the abstract player class.

Procedual immitation. Object-oriented languages can mimic procedual languages by offering classes with a single member function (subroutine) or a single member variable (data structure). It is difficult to immitate object-oriented languages in a procedual language even if you can combine data variables and functions into single structures. The structure would still miss encapsulation, abstraction, and inheritance.

Inheritance. Programmers of object-oriented languages distinguish between an ``is a'' and a ``has a'' relationship: only if an object is a specialization of the other object, should a programmer use inheritance. For a ``has a'' relationship a programmer should include a variable member of the related ``has a'' class. If in doubt, a ``has a'' relationship is preferable in non-abstract classes.


next up previous print clean
Next: Why Java? Up: Why object orientation? Previous: Why object orientation?
Stanford Exploration Project
3/8/1999