Skip to content

struct or class should be using for string? #532

Answered by SteveDunn
arteny asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @arteny - just catching up on some Vogen action! Apologies for the delay!
Whether or not to use a class/struct value object is the same as deciding whether to use a class/struct for any other type.
Some other frameworks for wrapping primitives, wrapped them all in a class, which had performance implications, as, for every instance, there was now heap pressure on the GC.

Structs are a natural choice for value objects as they are small, have value-equality, and are immutable.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@fbestfriends
Comment options

Answer selected by arteny
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants