Polymorphism of classes

21.12.2017

We can use class inheritance in ObjectGears. This enables us to define common properties of several classes in a single place and ensure that all classes possess these properties. Let`s take Configuration management as an example. All the configuration items have some common properties like e.g. unique code, owner of the configuration item, end of the lifecycle or various general relations to other configuration items as defined by ITIL.

At the same time they have completely different properties. E.g. in case of database we will be interested to see on which database server it is located, what is its size and back up plan. In case of devices (hardware) we need to know where it is located, in which security zone and till when we have a prepaid support. In case of server we should know its name, domain, operating system, membership in a farm or cluster, device, on which it is running, CPU, RAM, disks...

Therefore, we will define a parent class (Configuration items) with a common properties and child classes (database, device, server, rack, datacenter, aplication, process...), that contain specific properties. Child class can have further child classes. Number of inheritance levels is not limited. When displaying particular item we can see both inherited properties and properties defined in particular child.

We can also display relation of ObjectGears classes by means of a scheme. Each class in the scheme contains links to its definition, data and columns (properties).

Polymorphism of classes in Configuration database CMDB

How are we going to utilize polymorphism? We want to know status of all the configuration items and display it by means of a traffic light. We will define this property in the common parent class. However, the status will depend on specific properties of particular child classes. This is why we will perform definition of the status (common inherited class) in the child classes (by means of rules).