This is great and all but I would suggest that you make the Color class a value type. Specifically I would write it as readonly struct Color : IEquatable<Color>), this has a couple of advantages:
It's read-only (immutable) by default
Allocation-free when passing between methods (like with public Color Repaint(string hue, bool metallic))
Makes the intent more explicit (you want Color to represent some values) if no virtualization is required.
I'm focused on developing and expanding my knowledge and skills. Enjoying new challenges. I'm assuming that there are no stupid questions, there are only silly answers.
Thanks for your comment. You are completely right. My old habits (and laziness) won.
I had problems with storing Value Objects with Entity Framework. I’ve checked that even EF Core 2.0 doesn't support storage of struct objects.
In non-db scenarios read-only struct makes the job right. We need to keep in mind that C# 7.2 is required to use it. I added the struct version to the links too.
Point for you for your mindfulness.
Cheers.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
This is great and all but I would suggest that you make the
Color
class a value type. Specifically I would write it asreadonly struct Color : IEquatable<Color>
), this has a couple of advantages:public Color Repaint(string hue, bool metallic)
)Color
to represent some values) if no virtualization is required.Thanks for your comment. You are completely right. My old habits (and laziness) won.
I had problems with storing Value Objects with Entity Framework. I’ve checked that even EF Core 2.0 doesn't support storage of struct objects.
In non-db scenarios read-only struct makes the job right. We need to keep in mind that C# 7.2 is required to use it. I added the struct version to the links too.
Point for you for your mindfulness.
Cheers.