Re: What is the alternative to lack of C++ style "const" in C#

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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?
>


.



Relevant Pages

  • Re: xp and simple design
    ... I think the focus should not be "What practices do we ... Good developers need ... > agile have almost all moved very close to XP. ... Well that depends on the manager. ...
    (comp.object)
  • Re: About method comments
    ... If the technical staff all say waterfall process is best practice, ... planning that the developers were forced to shoulder. ... practices associated with XP and say those practices obviate the need ...
    (comp.lang.smalltalk)
  • Re: Newbie question on code vetting
    ... I know this is not a particularly fascinating topic for developers, ... was more transparency with respect to the practices observed within the ... committers across projects. ... With regard to the issue of trust, how can I either trust or decide not to ...
    (comp.lang.python)
  • Re: Building SQL query when table is two words...
    ... >> practices in code writing/database creation rather than ones which ... >>> developers are often fixing up someone else's work and don't have the ... >>> Bradley ... >>> A Christian Response ...
    (comp.databases.ms-access)
  • Re: Test Driven Development
    ... Reasonably wise and dedicated developers will ... Doing the XP practices day in and day out is not as important -- in my opinion ... I trust that if people were to practice these practices as much as I have, ...
    (comp.object)