Wednesday 15 October 2008

Classic C# Programming Offences (includes Managed C++ Gotchas)

  1. Not declaring your constructors as explictly public (unless of course you are programming a singleton) [minus 10 points]
  2. Trying to resize a text box vertically, when the multi-line property is set to false. [minus 5 points]
  3. Trying to click on the toolbox in Visual Studio when you're not in Design View. [minus 9 points]"
  4. Looking up the "Editable" property in a control when the correct property is "Read-only" (old school!) [minus 3 points]
  5. Using \n in a text box and expecting a newline (you need \r\n) [minus 5 points]
  6. Trying to pin the memory of a stack-allocated object like so: double d=5; fixed (double* ptrd = &d); you will get the error "cannot use fixed to take address of an already fixed expression". [minus 10 points - shows a fundamental lack of understanding of .NET memory management]
  7. Trying to create an array or vector of pinned pointers. [minus 5 points]
  8. Using new instead of gcnew in a Managed C++ program [minus 1 point]
  9. Returning null instead of NULL from Managed C++ (reversed for C#) [minus 5 points - you don't know MS C Compiler]
  10. Using ref to pass a reference type rather than a value type [minus 20 points]
  11. Trying to add a Scrollbar to a Panel (use AutoScroll property!) [minus 2 points]
  12. Writing a callback function as private.

No comments: