Version
- Tags:
- analysis
- class properties
CA013 - Exported creation procedure
Description
If acreation procedure is exported then it may be called by clients after the object has been created. Usually, this is not intended. A client might, for example, by accident call x.make
instead of create x.make
, possibly causing a class invariant or postcondition to not hold anymore.
Scope class Status Enabled Severity Warning Applicability All Score 50
Example of violation
class TEST create make feature -- Initialization make -- Initialize Current do end update do end end
Recommendation
Make sure to export the creation procedure to NONE.
In the example, add the export to NONE after the feature clause:
class TEST create make feature {NONE} -- Initialization make -- Initialize Current do end feature -- Initialization update do end end
Back to Rules