<- People Behind Informatics


All 0-9 A B C D E F G H I J K L M N O P Q R S T U V W XY Z




 
Dynamic Binding
A polymorphous procedure can be applied to objects of various classes (within the same class hierarchy). Often we need to adapt an algorithm more or less to accommodate the specific subclass. Therefore we can override methods of a superclass in its subclasses. Overriding means exchanging the algorithm of a method. If a truck’s acceleration is different from that of a sedan (trucks record speed in a logbook), then the subclasses Truck and Sedan can override the method to determine speed. The new method is invoked by the same message, but does something different, depending on whether the message was sent to a Sedan or a Truck object. The dynamic binding mechanism guarantees that – depending on which subclass an object belongs to – the correct method is always applied. An algorithm that determines the speed of different vehicles simply sends an object the “set speed” message. Which method is actually invoked depends on the type of the object. Thus the methods are not statically bound at compile time, but dynamically at run time, when actual class membership is available. Class hierarchy of vehicles

. Class Car serves as abstract superclass [Source: Laszlo Böszörmenyi, Carsten Weich; Programming in Modula-3; 1996]
 

 

<- People Behind Informatics


Home  |  Top  |  Search  |  Gallery  | Glossary  | Sitemap  |  Making Of  |  Help