/
11.01.2019 at 06:39 pm
Cuttings

Clarity of Liskov

Write clearly, especially with technical answers.

See this question, on the Liskov Substitution Principle:

"...I have heard that the Liskov Substitution Principle (LSP) is a fundamental principle of object oriented design. What is it and what are some examples of its use?"

See this answer - it hits the point straight, without need for unnecessary detail (which can be explored later):

The Liskov Substitution Principle (LSP, lsp) is a concept in Object Oriented Programming that states:

Functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it.

At its heart LSP is about interfaces and contracts as well as how to decide when to extend a class vs. use another strategy such as composition to achieve your goal.

Yet compare the above to the following:

LSP is necessary where some code thinks it is calling the methods of a type T, and may unknowingly call the methods of a type S, where S extends T (i.e. S inherits, derives from, or is a subtype of, the supertype T).

For example, this occurs where a function with an input parameter of type T, is called (i.e. invoked) with an argument value of type S. Or, where an identifier of type T, is assigned a value of type S.

val id : T = new S() // id thinks it's a T, but is a S

LSP requires the expectations (i.e. invariants) for methods of type T (e.g. Rectangle), not be violated when the methods of type S (e.g. Square) are called instead.

This answer not only lacks clarity, but is unnecessarily theoretical, difficult to understand, and worst of all: doesn't even answer the question. It seems as if the author is writing to impress, not to explain.

My thoughts are supported by some of the responses:

  1. You have mixed too many things. Things are not as confusing as you state them. Much of your theoretical assertions stand on flimsy grounds, like 'For knowledge to exist, unexpected possibilities much exist, .........' AND 'generally it is an undecidable problem whether any set is the subset of another, i.e. inheritance is generally undecidable' . You can start up a separate blog for each of these points. Anyways, your assertions and assumptions are highly questionable. One must not use things which one is not aware of!

  2. You are going in too many directions. This is not an answer.


Filed under:
#
#
Words: 422 words approx.
Time to read: 1.69 mins (at 250 wpm)
Keywords:
, , , , , , , , ,

Other suggested posts

  1. 23.03.2023 at 11:12 am / Copywork vs Master Studies
  2. 23.02.2021 at 09:34 pm / Counsel Citing Adverse Authorities
  3. 22.08.2018 at 02:13 pm / Heinrich Schliemann's Learning Method
  4. 08.12.2017 at 12:00 am / The Song of Java Braces
  5. 12.03.2016 at 12:00 am / Transcript of Tifa Funk - Interlude Solo (Tifa's Theme by Tetrimino)
  6. 11.08.2015 at 12:00 am / Proper Denials and Bare Denials
  7. 23.07.2015 at 12:00 am / The Line Between Gifts and Bribes
  8. 08.12.2013 at 12:00 am / Alien Blue Entrances
  9. 16.03.2012 at 12:00 am / Sentient Vocal Directives
  10. 16.08.2010 at 12:00 am / Lost Nuances in 'Ivan the Terrible'
© Wan Zafran. See disclaimer.