Changes between Version 33 and Version 34 of MapGuideCodingStandards


Ignore:
Timestamp:
Jan 26, 2015 5:01:31 AM (3 years ago)
Author:
jng
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • MapGuideCodingStandards

    v33 v34  
    66
    77||'''Revision'''||'''Date'''||'''Author'''||'''Comment'''||
     8||1.6.3||26 Jan, 2015||Jackie Ng||Added section about argument checking||
    89||1.6.2||9 Dec, 2012||Jackie Ng||More about C++ documentation||
    910||1.6.1||31 May, 2012||Jackie Ng||More about exception handling||
     
    153154
    154155Of course the same stack vs. heap thinking applies to non-ref-counted objects.
     156
     157== Argument Checking and Validation ==
     158
     159Where possible, avoid doing your own argument checking/validation and manually throwing exceptions for invalid method arguments and use one of the available macros to do this for you in {{{Foundation\System\Util.h}}}
     160
     161{{{
     162CHECKNULL(pointer, methodname) //Check that pointer is not null. Throws MgNullReferenceException if null
     163CHECKARGUMENTNULL(pointer, methodname) //Check that pointer is not null. Throws MgNullArgumentException if null
     164CHECKARGUMENTEMPTYSTRING(stlstring, methodname) //Check that given std::basic_string<T> is not empty. Throws MgInvalidArgumentException if empty
     165MG_CHECK_RANGE(value, min, max, methodname) //Check that given argument is within the specified range. Throws MgNullReferenceException if null
     166}}}
     167
     168These macros will not only do the requisite checks, but also capture the name of the offending argument and use the correct error message
    155169
    156170== Threading Guidelines ==