M
mswlogo
There are many threads on the lack of a true unmanaged C++ const like
behavior in C# (.Net) and that's not what this topic is about. The
topic is, what is the best practical way to live with it.
Some developers feel any function that returns an object should copy
it. This gets pretty expensive performance wise and development wise
and hard to enforce. It also defeats a lot of what C# intentionally
did.
Other developers feel you should build your own protection. This has
good performance but again. This is a high development cost to add to
all your objects and on a large team with faces coming and going and
wide range of experience, pretty hard to enforce.
The last option is, screw it, and don't worry about it. You'll create
more bugs or performance issues by trying to fix it than the problem
(lake of protection) will likely cause. Super critical objects could
be manually protected as needed. Hopefully good design will avoid most
issues.
What is your thoughts and practices?
behavior in C# (.Net) and that's not what this topic is about. The
topic is, what is the best practical way to live with it.
Some developers feel any function that returns an object should copy
it. This gets pretty expensive performance wise and development wise
and hard to enforce. It also defeats a lot of what C# intentionally
did.
Other developers feel you should build your own protection. This has
good performance but again. This is a high development cost to add to
all your objects and on a large team with faces coming and going and
wide range of experience, pretty hard to enforce.
The last option is, screw it, and don't worry about it. You'll create
more bugs or performance issues by trying to fix it than the problem
(lake of protection) will likely cause. Super critical objects could
be manually protected as needed. Hopefully good design will avoid most
issues.
What is your thoughts and practices?