This repository uses pattern matching with some errors:
The purpose of Match method is to avoid if/else checks by supplying set of callbacks to call. And each implementation calls respective callback. Something like a virtual methods in generic class, but strongly typed for pre-defined types.
There is no need to expose type-specific results in factory methods AttributeValue.StringAttributeValue. Simply returning IAttributeValue should suffice. So generic IAttributeValue<T> interface is not needed.
Implementation of IAttributeValue is trivial and there is no need to have interface and implementation separately - simple implementation class will suffice.
This repository uses pattern matching with some errors:
The purpose of
Match
method is to avoidif/else
checks by supplying set of callbacks to call. And each implementation calls respective callback. Something like a virtual methods in generic class, but strongly typed for pre-defined types.Issues:
AttributeValue
uses if/else instead of having separate classes with the hardcoded implementation of aMatch
method which will call the proper callback: https://github.com/census-instrumentation/opencensus-csharp/blob/d087855fb93440f678009173d3f0f4392b58ce52/src/OpenCensus.Abstractions/Trace/Internal/AttributeValue%7BT%7D.cs#L120-L149There is no need to expose type-specific results in factory methods
AttributeValue.StringAttributeValue
. Simply returningIAttributeValue
should suffice. So genericIAttributeValue<T>
interface is not needed.Implementation of IAttributeValue is trivial and there is no need to have interface and implementation separately - simple implementation class will suffice.