![]() What’s Composition?Ĭomposition is a concept that models a has a relationship. You’ll see in this article why you should always follow the Liskov substitution principle when creating your class hierarchies, and the problems you’ll run into if you don’t. ![]() The principle states that “in a computer program, if S is a subtype of T, then objects of type T may be replaced with objects of type S without altering any of the desired properties of the program”. This is known as the Liskov substitution principle. ![]() This means that Horse inherits the interface and implementation of Animal, and Horse objects can be used to replace Animal objects in the application. The inheritance relationship states that a Horse is an Animal. Let’s say you have a base class Animal and you derive from it to create a Horse class.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |