Carl Dea recently followed up on a blog post of mine called Save Memory! Use Shadow Fields for Properties. In his blog he suggested the use of an interface called “Property Accessor” to eliminate the heavy use of boilerplate code that is needed in order to use shadow fields. Carl also mentioned that he hasn’t tested his approach with a lot of data and that he or some reader might follow up with a performance comparison. So here it comes.
I wrote a small test application that implements the three strategies that Carl mentions in his post:
- standard properties that are instantiated at the same time when the class gets instantiated
- property accessor interface as proposed by Carl
- shadow fields as proposed in my recent blog post