Search code examples
orleans

Immutable attribute or Immutable wrapper object - which one?


Quick question for those that might know!

It appears there are two ways to mark a message as immutable in Orleans..

new Immutable(...) or with an attribute [Immutable] on the message class

Which is preferred and more importantly why - or is it just a matter of personal taste?


Solution

  • [Immutable] applies to all instances of that class (everywhere you use it, the instances of this class will be considered as Immutable), while new Immutable(...) applies to every instance usage (at one place you can pass your class as mutable and at other place as Immutable). If all instances of this class will be always Immutable, [Immutable] is a more terse and elegant approach.