Efficient Decorator Pattern Variants through C++ Policies

Virginia Niculescu

2020

Abstract

C++ Policies represent an interesting metaprogramming mechanism that allows behavior infusion in a class. In this paper, we will investigate the possibility of using them for the implementation of some extended Decorator pattern variants. For the MixDecorator variant, policies are used to simulate extension methods, which are needed for implementation. Beside this, other two alternatives for Decorator pattern are proposed: one purely based on inheritance, and another that is a hybrid one; the last one wraps an object with decorations defined as a linear hierarchy of classes – introduced using policies. This is possible since a policy introduces a kind of recursive definition for inheritance. The advantages and disadvantages of these variants are analyzed on concrete examples. The hybrid variant presents many important advantages that qualify it as a valid and efficient Decorator pattern variant – HybridDecorator.

Download


Paper Citation


in Harvard Style

Niculescu V. (2020). Efficient Decorator Pattern Variants through C++ Policies.In Proceedings of the 15th International Conference on Evaluation of Novel Approaches to Software Engineering - Volume 1: ENASE, ISBN 978-989-758-421-3, pages 281-288. DOI: 10.5220/0009342802810288


in Bibtex Style

@conference{enase20,
author={Virginia Niculescu},
title={Efficient Decorator Pattern Variants through C++ Policies},
booktitle={Proceedings of the 15th International Conference on Evaluation of Novel Approaches to Software Engineering - Volume 1: ENASE,},
year={2020},
pages={281-288},
publisher={SciTePress},
organization={INSTICC},
doi={10.5220/0009342802810288},
isbn={978-989-758-421-3},
}


in EndNote Style

TY - CONF

JO - Proceedings of the 15th International Conference on Evaluation of Novel Approaches to Software Engineering - Volume 1: ENASE,
TI - Efficient Decorator Pattern Variants through C++ Policies
SN - 978-989-758-421-3
AU - Niculescu V.
PY - 2020
SP - 281
EP - 288
DO - 10.5220/0009342802810288