Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LG 03-04: add additional reason/goal for LSP #600

Open
kraemerdr opened this issue Oct 11, 2024 · 10 comments
Open

LG 03-04: add additional reason/goal for LSP #600

kraemerdr opened this issue Oct 11, 2024 · 10 comments
Assignees
Labels
help wanted Extra attention is needed question Further information is requested V2025 Release 2025

Comments

@kraemerdr
Copy link

kraemerdr commented Oct 11, 2024

Aus meiner Sicht ist das primäre Ziel hinter dem LSP weniger "Konsistenz und konzeptionelle Integrität", sondern eher Robustheit (daher auch Teil von SOLID). Wenn sich konkrete Bausteine an die Schnittstellenverträge ihrer Abstraktionen halten, ist weniger unerwartetes (und damit in aller Regel fehlerverursachendes) Verhalten zu erwarten.

Den Aspekt der Robustheit würde ich also zumindest ergänzen:
"Liskov’sches Substitutionsprinzip [Liskov 1994] als eine Möglichkeit, Konsistenz, konzeptionelle Integrität und Robustheit zu erreichen (R3)."

@gernotstarke gernotstarke added help wanted Extra attention is needed question Further information is requested V2025 Release 2025 labels Oct 12, 2024
@gernotstarke
Copy link
Member

That's a good argument - although I still see LSP as a purely OO topic.

@mahboubagharbi
Copy link

LSP:semantische Integrität und Konsistenz 😉

@gernotstarke gernotstarke self-assigned this Oct 13, 2024
@kraemerdr
Copy link
Author

That's a good argument - although I still see LSP as a purely OO topic.

Although I have to admit being a huge fan of LSP, I fully agree and would even be fine with removing it from an architecture (!) training altogether. However, if we decide to keep it, linking it to robustness at least provides a justification for its selection.

@alxlo
Copy link
Contributor

alxlo commented Oct 14, 2024

I'm fine with keeping it as R3, although it will not get a (full) slide in my slide deck as exposing the audience to "Let ⁠ ϕ ( x ) be a property provable about objects ⁠ x of type T. Then ⁠ ϕ ( y ) should be true for objects ⁠ y of type S where S is a subtype of T." leads to a VERY hard and immediate shut down of at least 50% of the participants in my class room. Especially if they don't have an OOP background.

although I still see LSP as a purely OO topic.

au contraire ;-)

Elaborating on behavioral subtyping and that you do not want to care about possible "VIP behaviour" of your specializations/implementations is something that (almost) everyone can relate to and that works fine without OOP and also on multiple levels of architectural design and IMHO conceptually relates strongly to backward compatibility.

@mikesperber
Copy link
Contributor

The original paper is about type safety, so it is up to us to speculate on the architectural implications of this.

SOLID's take on LSP is that it's about consistency:

https://blog.cleancoder.com/uncle-bob/2020/10/18/Solid-Relevance.html

I'm unsure what "robustness" means in this context, so I'm mildly opposed to adding it.

@kraemerdr
Copy link
Author

In this case robustness corresponds to the absence of unexpected (and therefore potentially erroneous) behavior that results from components violating the interface contracts given by their abstractions. Example: read-only implementations of the List interface in Java that cause UnsupportedOperationExceptions in arbitrary parts of the code.

@mikesperber
Copy link
Contributor

In this case robustness corresponds to the absence of unexpected (and therefore potentially erroneous) behavior that results from components violating the interface contracts given by their abstractions. Example: read-only implementations of the List interface in Java that cause UnsupportedOperationExceptions in arbitrary parts of the code.

Then "robustness" is not the right word. (Cf. https://en.wikipedia.org/wiki/Robustness), which is about reaction to change. The correct term would be "type safety" or "type soundness".

@kraemerdr
Copy link
Author

kraemerdr commented Oct 18, 2024

From my perspective robustness is not necessarily limited to change, but rather describes the ability to continue operations under difficult circumstances (as described in the German version of the Wikipedia article you referenced):

In der Informatik und Softwareentwicklung bedeutet der Begriff „Robustheit“ die Eigenschaft eines Verfahrens, auch unter ungünstigen Bedingungen noch zuverlässig zu funktionieren.

Avoiding unexpected behavior due to conformity to specified interfaces supports this goal. Type safety on the other hand is more a means than a goal IMHO.

@mikesperber
Copy link
Contributor

From my perspective robustness is not necessarily limited to change, but rather describes the ability to continue operations under difficult circumstances (as described in the German version of the Wikipedia article you referenced):

OK - but what are the "difficult circumstances" in this context?

@gernotstarke
Copy link
Member

We are discussing an R3-topic here, just to put the length of the discussion in some context.

I conclude by proposing the following compromise:

DE: "Liskov’sches Substitutionsprinzip als eine Möglichkeit, Konsistenz, konzeptionelle Integrität und Robustheit (im Sinne von Typsicherheit) zu erreichen (R3)."

EN: “Liskov's Substitution Principle as a way to achieve consistency, conceptual integrity and robustness (in the sense of type safety) (R3).

@gernotstarke gernotstarke changed the title LG 03-07: Erweiterung der Ziele hinter LSP LG 03-04: Erweiterung der Ziele hinter LSP Oct 28, 2024
@gernotstarke gernotstarke changed the title LG 03-04: Erweiterung der Ziele hinter LSP LG 03-04: add additional reason/goal for LSP Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested V2025 Release 2025
Projects
Status: waiting-for-approval
Development

No branches or pull requests

5 participants