Free cookie consent management tool by TermsFeed Policy Generator
wiki:Documentation/DevelopmentCenter/BestPractices

Version 3 (modified by abeham, 10 years ago) (diff)

--

General Coding Best Practices

  • use Environment.NewLine instead of the string constant "\n"
  • use Path.Combine() instead of string concatenation (with \ or /) to combine directory and file names
  • throw and catch specific exceptions, don't catch generic exceptions try { ... } catch(Exception ex) {}
  • use a finally block to make sure that the state of the program is consistent even when Exceptions are thrown
  • if the mouse pointer was changed, set the mouse pointer back to normal in a finally {... } block
  • use string.Empty instead of the string constant ""
  • use string.IsEmptyOrNull(a) instead of if(a!=null && a!="")
  • check for InvokeRequired in methods that manipulate GUI elements in controls
  • instantiate all objects of classes implementing IDisposable with the using(...) { ... } statement to make sure the object is disposed correctly
  • Types and the namespaces they are defined in should not be named similarly, e.g. HeuristicLab.Encodings.MyEncoding should not contain the equally named class MyEncoding.

Developing Operators

  • When defining ValueParameters inside an operator also include a public property that allows get and set access to the parameter's Value property.
  • Use interfaces instead of concrete classes (e.g. when implementing parameter properties expose an IValueParameter<T> instead of a ValueParameter<T>)