CODESYS - Runtime polymorphism using an ITF (OOP)

AT&U
AT&U
2.5 هزار بار بازدید - 3 سال پیش - Source code:
Source code: https://github.com/ATandU?tab=reposit...

- Polymorphism is one of the pillars of the OOP and means "Having many forms"
- There is a Compile-time polymorphism also known as static polymorphism or early binding and it can be achieved with functions overloading. (not only)
- The Runtime-time polymorphism also known as dynamic polymorphism or late binding and it is when the function call is resolved at run time. That means, that the specific function to call will be determined at runtime based on the object’s dynamic type. (In our case the ellipse and the rectangle and the M_Area to be invoked)
- In this video, the runtime polymorphic behavior is achieved with an ITF that is implemented by two FB's. The FB's are shapes and have a common property area.
- The object ITF describes a set of method and property prototypes. That means that the methods and properties contain only declarations and no implementation. The implementation must be provided by the FB's that implement the ITF. This allows different function blocks, that have common properties, to be used in the same way. (Calculating the Area of a Shape in our case)
- All the methods and properties in the ITF have the access specifier public.
- The Properties are an extension of the IEC standard and a tool for object-oriented programming. They are used for data encapsulation because they allow external access to data. For this purpose, a property provides the accessor methods Get and Set which allows read and write access to the encapsulated data.
3 سال پیش در تاریخ 1400/08/28 منتشر شده است.
2,575 بـار بازدید شده
... بیشتر