Re: What is the alternative to lack of C++ style "const" in C#
- From: "Nicholas Paldino [.NET/C# MVP]" <mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 13 Jul 2005 12:33:53 -0400
mswlogo,
Not to be flippant, but I take option #3 (screw it). While I do see the
practical application of const in C++, the fact that you can just cast it
away made the statement (in my eyes) pretty worthless.
Also, I'm a strong believer in the last statement in option #3, that
good design will alleviate this in most cases (of course not all, but that's
the ideal).
--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx
"mswlogo" <mswlogo@xxxxxxxxxxx> wrote in message
news:1121272021.145550.38890@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> 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?
>
.
- Follow-Ups:
- Re: What is the alternative to lack of C++ style "const" in C#
- From: TT (Tom Tempelaere)
- Re: What is the alternative to lack of C++ style "const" in C#
- References:
- Prev by Date: Re: Choosing Exception objects
- Next by Date: Re: What is the alternative to lack of C++ style "const" in C#
- Previous by thread: What is the alternative to lack of C++ style "const" in C#
- Next by thread: Re: What is the alternative to lack of C++ style "const" in C#
- Index(es):
Relevant Pages
|