[Home]ObjectOrientedProgramming

Robo Home | Changes | Preferences | AllPages

From Wikipedia.org entry for OOP:

The idea behind object-oriented programming is that a computer program is composed of a collection of individual units, or objects, that act on each other, as opposed to a traditional view in which a program is a list of instructions to the computer. Each object is capable of receiving messages, processing data, and sending messages to other objects.

Object-oriented programming is claimed to give more flexibility, easing changes to programs, and is widely popular in large scale software engineering. Furthermore, proponents of OOP claim that OOP is easier to learn for those new to computer programming than previous approaches, and that the OOP approach is often simpler to develop and to maintain, lending itself to more direct analysis, coding, and understanding of complex situations and procedures than other programming methods.

One of my early design adventures in Robocode was to model the physics with OOD. I have position (x,y), heading, and velocity objects, for both static and dynamic versions (static cannot be updated), and combinations representing a vector (static heading and velocity), projectile (dynamic position and static vector), and vehicle (dynamic position, heading, and velocity). The objects have methods to allow comparison or addition with other objects. For example, I can add a vector to a dynamic position and move the position one unit forward. I can compare two positions and get either the distance or the bearing from one to the other. Other stuff as well, handled by the objects rather than calling some generic class that holds math routines. By modeling them with interfaces (and implementations) I am able to pass a vehicle to a method that wants a static position, for example, and other polymorphic stuff. -- Martin / Ugluk


Robo Home | Changes | Preferences | AllPages
Edit text of this page | View other revisions
Last edited December 29, 2005 17:38 EST by Martin Alan Pedersen (diff)
Search: