Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider introducing a non-generic ValueObject #2

Open
EamonNerbonne opened this issue May 29, 2014 · 0 comments
Open

Consider introducing a non-generic ValueObject #2

EamonNerbonne opened this issue May 29, 2014 · 0 comments

Comments

@EamonNerbonne
Copy link
Owner

This would have a little less syntactic overhead, which is practical. However, there are downsides:

  1. I can't implement a type-safe IEquatable<> anymore.
  2. I'd need to resolve the equalitycomparers per-instance and not per type since there'd be only one type - ValueObject. That means constructing such types would need a thread-safe dictionary lookup (imposing a little perf overhead), and every object would be one reference larger - the reference to the comparer. Furthermore, calls to GetHashCode/Equals would be one pointer indirection further away, which will also cause performance to drop. I'd expect this to be competitive with Tuple<>'s implementation, and still significantly faster than ValueType's.
  3. Alternatively, I could postpone the comparer lookup to GetHashCode/Equals time, but that means they'd be even slower although I'd avoid penalizing instance creation and avoid the extra object size.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant