title: Use of Assert and NULL pointer validation what's better to use
body: <p>While doing programming i am using assert as well as NULL pointer validation.</p>
  
  <p>But as i know assert will be useful only in <strong>DEBUG</strong> mode.</p>
  
  <p>My question is suppose i have a internal pointer which i am sure cant be NULL example function returning a pointer(but the pointer is not a member of class) in such cases i can use <strong>assert</strong> </p>
  
  <pre><code>test* ptr = fun(); // return a pointer of type test
  assert(ptr);
  
  //do some operation
  </code></pre>
  
  <p>or <strong>NULL</strong> pointer validation  </p>
  
  <pre><code>test* ptr = fun(); // return a pointer of type test
  assert(ptr);
  if (NULL != ptr)
  {
      //do some operation
  }
  </code></pre>
  
  <p>Here which code practice is good.As per my understating it will be second one.
  Because i have faced some situations where the value of <strong>ptr</strong> returns <strong>NULL</strong> due to some abnormal cases that we cant even think of.</p>
  
  <p>But do we have any other better options?</p>