Robo Home | Changes | Preferences | AllPages

Polymorphism in robocode robots means having several classes that do something (e.g. spin the radar) all implementing a common method. The bot then switches between the modes using ModeSelection. --David Alves

Polymorphism is a general programming term, often held as one of the powerful strengths of ObjectOrientedProgramming. There are several ways to achieve Polymorphism with Java, inlcuding Inheritance?, Interface?s and several DesignPatterns like DesignPatterns/Strategy? and DesignPatterns/State. -- PEZ

The Power of Polymorphism
Polymorphism, Greek for "many forms", means that you can hide many alternative implementations behind a common interface. In Java and other OO languages this is done by inheritance (either direct inheritance of classes or by interface based inheritance). Basically it means that you can switch in alternative strategies and hide (or in OO speak - encapsulate) the code that performs the operation behind a known and public API. This ability means that you can create 'loosely-coupled' applications that allow new strategies to be added with the minimum amount of disruption.

Interfaces are probably one of the hardest concepts to understand for the newbie Java/OO developer and consequentially are used a lot less frequently than they should be IMHO. Easiest way to think of an interface is basically as a contract that defines the signatures of the methods that the classes HAVE to deliver.

Sorry for the lesson, i've been reading again:)Hexkid

Robo Home | Changes | Preferences | AllPages
Edit text of this page | View other revisions
Last edited March 28, 2003 0:07 EST by Hexkid (diff)