Superclass property implementation
ID | FCNS-23 |
Title | Classes shall not implement properties inherited from superclasses. |
Priority | Mandatory |
Severity level | 1 |
Description | Classes shall not implement concrete properties that are inherited from a superclass. In order to assign default values to concrete properties inherited from a superclass, assign the values in the constructor of the subclass, or make the properties Abstract in the superclass. |
Rationale | Attempting to use such a class will result in a runtime error. |
Exception | There are two separate conditions under which you can redefine superclass properties: The inherited property is abstract. The values of the superclass property SetAccess and GetAccess attributes are private. |
Avoid:
classdef Measurement
properties
measurementDate
end
end
classdef Pressure < Measurement
properties
measurementDate = today()
end
end
Instead use:
classdef Measurement
properties
measurementDate
end
end
classdef Pressure < Measurement
methods
function obj = Pressure()
obj.measurementDate = today();
end
end
end