Talk:A-level Computing/AQA/Paper 1/Fundamentals of programming/Object-oriented programming

I saw your post on CAS site about this. Im not sure you have polymorphism quite correct - its a property of the objects. A procedure messages an object to invoke a method, and any object which provides the method requested can comply. The messaging procedure doesnt need to know what class of object is being messaged. The methods are defined in classes (A,B,..) with the same method name, and so can only access the variables for their own class. Your last sentence seems to describe operator overloading, where the appropriate class method is selected, according to the type of the other operand ?

I suggest -

"Instead, OOP languages introduce a new feature: Polymorphism.

Polymorphism describes the situation where different classes implement methods with the same name, and return the required values, calculated appropriately for the class in question. For example, shape.area would invoke a method from the class of which shape is an instance, which would be different methods when shape was an instance of a polygon or an ellipse.

The method can be selected at run time, so that the code which invokes shape.area need not know what class shape belongs to, so long as the class provides a method area."

Jim Conboy

Jim Conboy (discuss • contribs) 21:14, 16 April 2016 (UTC)