![]() ![]() ![]() Representative does not share the same relationship of the objects that they represent.Treat square and rectangle completely different type.This is a violation of Open Close Principle. Dependency will be created when fixing the problem by checking if a Rectangle is a Square in the program. ![]() When program setHeight on an object of square, there is an undefined behavior of how to handle a setHeight in a square.Rectangle and subtype Square with setHeight and setWidth vs setSide.Exception and side effect by the subtype that the base type didn’t expect.Refused Bequest is when an object invoke a method or send a message that is not expected.Invoking method vs Send Message (Static vs dynamic language).What is wanted here is something like the following substitution property: If for each object 01 of type of S there an object 02 of type T such that for all programs P defined in term of T, the behavior of P is unchanged when 01 is substituted for 02 then S is a subtype of T.A subtype relationship of described point as a subtype of point is when described point can be cast into point but not visa versa.Similar to a class, a class is nothing but its methods and the data is hidden as private.A Type is a bag of operations and how the data is stored is not matter to us as long as the operation is done correctly.Solution is typing to avoid paradox loop.“This statement is false” is a paradox.This episode talks about the principle govern inheritance, polymorphism and subtyping. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |