mongo-csharp-driver icon indicating copy to clipboard operation
mongo-csharp-driver copied to clipboard

Strategy pattern for BsonClassMapSerializer

Open dnickless opened this issue 7 years ago • 1 comments

The BsonClassMapSerializer.DeserializeClass(BsonDeserializationContext context) method contained code to handle two basic cases depending on the value of _classMap.HasCreatorMaps: The deserialization using a Dictionary<string, object> and the "standard" deserialization. By introducing a strategy pattern I could reduce branching (minor performance gain in theory but potentially wiped out due to additional method calls, I get varying results...) and refactor the code into a more OO kind of layout.

dnickless avatar Jun 21 '17 12:06 dnickless

I just rebased and optimized the suggested refactoring. Also, there now is some performance-relevant change (less repeated usage of reflection) included which - should you wish not to merge the refactoring part - could be applied to the current code base separately.

dnickless avatar Dec 09 '20 05:12 dnickless

Hi @dnickless, thank you for this architectural improvement suggestion. We are going to make some major refactoring in this area in scope of improving serialization epic CSHARP-3230, and unfortunately the proposed changes don't align with the current roadmap. Therefore we are closing this PR.

BorisDog avatar Mar 04 '24 22:03 BorisDog