Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 10
    The example does not violate LSP only as long as we constrain the semantics of Database::selectQuery to support just the subset of SQL supported by all DB engines. That's hardly practical... That said, the example is still easier to grasp than most others used here. Commented Feb 25, 2018 at 13:02
  • 6
    I found this answer the easiest to grasp out of the rest. Commented Feb 11, 2019 at 17:14
  • 1
    is it practical to apply LSP on databases? i see that most, if not all the, of db operations will need to be wrapped, and is vulnerable to mistakes. Though the good side is the API stays the same even if it's SQL vs NoSQL. Commented Aug 23, 2020 at 15:59
  • I find that example misleading. It causes the notion that strictly typed languages ensure the satisfaction of LSP. And from my POV the example that you provided is not a valid example. There is no base class and existing behaviour here, there are two different implementations of an interface. Commented Mar 6 at 9:56