Author

I am Joannes Vermorel, founder at Lokad. I am also an engineer from the Corps des Mines who initially graduated from the ENS.

I have been passionate about computer science, software matters and data mining for almost two decades. (RSS - ATOM)

Meta
« Screwturn powered front-end for your mISV | Main | Buyer's guide to development outsourcing »
Tuesday
Jun122007

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 | Unregistered CommenterRoss Ylitalo
Comments for this entry have been disabled. Additional comments may not be added to this entry at this time.