Overriding vs. Overloading

Both overriding and overloading are concepts in object-oriented programming that allow you to define methods with the same name but different behavior. However, they differ in their implementation and purpose. Overriding Overriding is a mechanism by which a subclass can provide a different implementation of a method that is already defined in its superclass. When a method is overridden, the subclass’s implementation takes precedence over the superclass’s implementation, allowing you to customize the behavior of the method for the specific subclass....

April 12, 2023 · aaron

Duck Typing

Duck typing is a concept in dynamic programming languages like Python, where the type of an object is determined not by its class name, but by its behavior or the methods and attributes it defines. The term “duck typing” comes from the phrase “if it looks like a duck, swims like a duck, and quacks like a duck, then it probably is a duck.” In Python, duck typing means that an object’s suitability for a given task is determined by the presence of specific methods or attributes, rather than its type....

April 6, 2023 · aaron