From f52fe43ba3bea5e9f5091445513279f800494760 Mon Sep 17 00:00:00 2001 From: Simeon Simeonov Date: Mon, 7 Nov 2022 05:50:13 +0100 Subject: Update notebooks/python/python_3_8_to_3_11.ipynb and notebooks/python/python_oo.ipynb --- notebooks/python/python_oo.ipynb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'notebooks/python/python_oo.ipynb') diff --git a/notebooks/python/python_oo.ipynb b/notebooks/python/python_oo.ipynb index 9f0774a..fe717a9 100644 --- a/notebooks/python/python_oo.ipynb +++ b/notebooks/python/python_oo.ipynb @@ -735,7 +735,7 @@ "In object-oriented programming, inheritance is the mechanism of basing an object or class upon another object (prototype-based inheritance) or class (class-based inheritance), retaining similar implementation. Also defined as deriving new classes (sub classes) from existing ones such as super class or base class and then forming them into a hierarchy of classes.\n", "\n", "In most class-based object-oriented languages, an object created through inheritance, a \"child object\", acquires all the properties and behaviors of the \"parent object\" , with the exception of: constructors, destructor, overloaded operators and friend functions of the base class. \n", - "Inheritance allows programmers to create classes that are built upon existing classes, to specify a new implementation while maintaining the same behaviors (realizing an interface), to reuse code and to independently extend original software via public classes and interfaces.\n", + "Inheritance allows programmers to create classes that are built upon existing classes, to specify a new implementation while maintaining the same behaviors (realizing an interface), to reuse code and to independently extend original software via public classes and interfaces. It is a \"is-a\" relationship between base (parent) class and a derived (child) class.\n", "\n", "One can simply view inheritance as a tool for code reuse.\n", "\n", @@ -1048,7 +1048,13 @@ "\n", "Not all classes admit a linearization. There are cases, in complicated hierarchies, where it is not possible to derive a class such that its linearization respects all the desired properties. \n", "`TypeError: Cannot create a consistent method resolution order (MRO) for bases X, Y` is raised then.\n", - "\n" + "\n", + "\n", + "## The Liskov substitution principle (LSP):\n", + "\n", + "Functions that use references to base class objects must be able to use objects of derived classes without knowing it.\n", + "\n", + "In other words: an object (such as a class) may be replaced by a sub-object (such as a class that extends the first class) without breaking the program.\n" ] }, { -- cgit v1.3