I want to take exception to the example being used to explain polymorphism. We need to get beyond "Hello World" and travel to the "Real World". This is CLSA 7.x training.
We want to create reusable data models. We also want to create reusable business logic.
Pattern inheritance is OPTIONAL. Nevermind mind its Pega Best Practice, lets not forget that.
Data should be for representing STATE, NOT BEHAVIOR. In the "Hello World", Shape::Draw(), Rectangle:Draw() works for explaining the concept. If one is programming in language such as DotNet / Java it is less of an issue. When developers out of college see example provided in this Pega lesson, they are forever corrupted.
Ins-Quote-Data-Vehicle and Ins-Quote-Data-Vehicle-Car
Pattern inheritance is fine when we are using it to inherit Work-. That's a manifestation of the ECS recommendations from PEGA where business logic can be customized across differet levels of an organization (i.e. Divisions). If one wants to define Data Models that can be appropriately extended and built upon AND shared across the organization, then one should not define 'Vehicle' in a particular division that manages Insurance Quotes only. It prevents other divisions who need 'Vehicle' from inheriting it since they are in another branch of the ECS and 'Vehicle' is not visible.
For Data, DIRECT INHERITANCE should be used, as in
Both 'Car' and 'Truck' in above example can inherit DIRECTly from 'Vehicle'. Ideally/possibly 'Vehicle' and even 'Car', 'Truck', etc. might be in SomeFramework-Data- layer. Regardless, 'Car', 'Truck', etc. should not pattern inherit from 'Vehicle'. Pattern inheritance for Data feels so wrong in so many ways.
***Updated by moderator: Lochan to move the post from Pega Product Support community***
A file system is the most common example. Beneath the root directory, where a number of files can be stored, multiple root subfolders can exist. A subfolder can contain files, as well, plus can contain its own subfolders, so on and so forth, ad-infinitum. The closer a folder is to the root, the more general it is; the farther away from the root the more specialized a folder is.