5

Few traps for former C++ developers coding in C#

 3 years ago
source link: https://blog.vermorel.com/journal/2007/6/12/few-traps-for-former-c-developers-coding-in-c.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Few traps for former C++ developers coding in C#

I have been proofreading a couple of time C# source code written by former C++ developers. Also C# and C++ have a lot in common at the syntax level, the conceptual framework underlying the two languages is really different. This post is a negligible attempt to point out the most common issues.

C# is garbage collected. You should not need any destructor. If you are using destructors, then it’s probably wrong 99% of the time. If you have doubts, ignore destructors, it’s the way to go with garbage collected languages.

Pre-processor statements are deprecated. Although C# does have statements like #if #else #endif, the pre-processor statements are de-facto a deprecated construct in C#. Like destructors, they are some very specific cases where those statements can be used. Yet, 99% of the time, using those statements would just be a design mistake.

C# comes with native guidelines. Microsoft has published very extensive guidelines about variable, method, class naming. Every single C# line you write is expected to be compliant with those guidelines.


Reader Comments (1)

I agree that the most important thing is standards, and I will conform, but I confess I already miss type and skope prefixes, i.e., m_lngEmployeeID. Perhaps after using the new conventions, I will easily make the adjustment. In today’s IDEs, after all, you merely need place your mouse cursor over the variable and the tooltip tells you nearly everything you need to know. I thought to myself, “hmmm, does that include scope in my IDE (VS 2005)?” Well, it’s not perfect, but it has come a long way! Ross June 12, 2007 | Ross Ylitalo


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK