When you compute hashCode, e.g.
result = result*prime + date.hashCode;
you need to apply mask to prevent going beyond smi:
const MASK=(1<<31)-1;result = ((result*prime)&MASK + date.hashCode)&MASK;
I think it would be a good idea for dart to provide some standard function to help compute hashCode.
There's an issue for this: https://code.google.com/p/dart/issues/detail?id=3597
Because hashCode is expensive, you better cache it in your Trade object.
What is overkill and what is not - depends on taste. To me, both TradeBuilder and TradeType look unnecessary.
For trade type, I would use just strings "buy" and "sell".
(There's a plan to introduce enum types in dart, then it will be easier. Right now, it's too much code for basically nothing)
Please note that for every advice, somebody else can give you the opposite advice :-)
When you compute hashCode, e.g.
result = result*prime + date.hashCode;
you need to apply mask to prevent going beyond smi:
const MASK=(1<<31)-1;result = ((result*prime)&MASK + date.hashCode)&MASK;
I think it would be a good idea for dart to provide some standard function to help compute hashCode.
There's an issue for this: https://code.google.com/p/dart/issues/detail?id=3597
Because hashCode is expensive, you better cache it in your Trade object.
What is overkill and what is not - depends on taste. To me, both TradeBuilder and TradeType look unnecessary.
For trade type, I would use just strings "buy" and "sell".
(There's a plan to introduce enum types in dart, then it will be easier. Right now, it's too much code for basically nothing)
Please note that for every advice, somebody else can give you the opposite advice :-)
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
When you compute hashCode, e.g.
result = result*prime + date.hashCode;
you need to apply mask to prevent going beyond smi:
const MASK=(1<<31)-1;result = ((result*prime)&MASK + date.hashCode)&MASK;
I think it would be a good idea for dart to provide some standard function to help compute hashCode.
There's an issue for this: https://code.google.com/p/dart/issues/detail?id=3597
Because hashCode is expensive, you better cache it in your Trade object.
What is overkill and what is not - depends on taste. To me, both TradeBuilder and TradeType look unnecessary.
For trade type, I would use just strings "buy" and "sell".
(There's a plan to introduce enum types in dart, then it will be easier. Right now, it's too much code for basically nothing)
I think it would be a good idea for dart to provide some standard function to help compute hashCode.
There's an issue for this: https://code.google.com/p/dart/issues/detail?id=3597
quiver.core has a nice Jenkins Hash implementation: http://google.github.io/quiver-dart/#quiver/quiver-core