In order to attach additional responsibilities to an object dynamically, the Decorator Pattern provides a technique to extend the functionality as a Wrapper:
The following summary shows us how CKJM Metrics have been affected in this project after having applied the Decorator Pattern:
CKJM Metric | Without the Pattern | With the Pattern |
---|---|---|
WMC: Weighted methods per class | 2.6 | 2.6 |
DIT: Depth of Inheritance Tree | 1 | 1 |
NOC: Number of Children | 0 | 0 |
CBO: Coupling between object classes | 3.4 | 3.8 |
RFC: Response for a Class | 4.9 | 4.7 |
LCOM: Lack of cohesion in methods | 0.4 | 0.4 |
Ca: Afferent coupling (not a C&K metric) | 1.6 | 1.8 |
NPM: Number of Public Methods for a class (not a C&K metric) | 2.3 | 1.9 |