liskov-substitution-principle
Is it okay to break LSP for the sake of binding?
Something tells me I might get lynched for asking this. And sorry for the long winded description in advance.[详细]
2023-04-11 15:37 分类:问答Hierarchy violates Liskov - so what?
I am using an API that violates the Liskov substitution principle : it throws its own Exception type that extends Exception, but puts the exception message from the base class in a new ErrorCode field[详细]
2023-03-25 15:18 分类:问答rationale behind Java's exception hierarchy
I find Java\'s exception hierarchy confusing. Throwable is divided into Error and Exception, and RuntimeException inherits from Exception.[详细]
2023-03-25 02:43 分类:问答Inheritance and LSP
Apologies in advance for a long-winded question. Feedback especially appreciated here . . . In my work, we do a lot of things with date ranges (date periods, if you will). We need to take all sorts o[详细]
2023-03-14 02:07 分类:问答Do abstract properties violate the Liskov substitution principle?
Suppose I have an abstract class like: public abstract class Pet { private final String name; public Pet(String name) {[详细]
2023-03-10 15:01 分类:问答Why array implements IList?
See the definition of System.Array class public abstract class Array : IList, ... Theoretically, I should be able to write this bit and be happy[详细]
2023-03-05 00:16 分类:问答Is my lecturers definition of the Liskov Substitution Principle incorrect, or am I misunderstanding?
The following does work because of the (Liskov) substitution principle, which says that if a reference is expected of an instance of a certain class then you may substitute a reference to an instance[详细]
2023-02-26 16:02 分类:问答Adapter Pattern vs Liskov Substitution
The Adapter design pattern is used to convert the interface of a class (Target) into another interface (Adaptee) clients expect. Adapter lets incompatible classes work together that could not otherwis[详细]
2023-02-13 16:15 分类:问答Why declare an instance as a supertype but instantiate it as a subtype, plus Liskov Substitution Principle
I\'ve been trying to understand the Liskov Substitution Principle for a couple of days now, and while doing some code tests with the very typical Rectangle/Square example, I created the code below, an[详细]
2023-02-08 05:26 分类:问答Aggregate class extending base class - Violation of LSP?
The Liskov Substitution Principle (LSP) on Wikipedia Say I have a Alien class with an numFingers attribute*.Occasionally, I need to pull the sum of the numFingers from the database, grouped by othe[详细]
2023-02-05 20:09 分类:问答