title: C++ detail namespace vs anonymous vs private method to class vs. pimpl vs. friend class
body: <p>Bear with me here. 
  I am trying to figure out at what point do you draw the line regarding putting helper methods in anon vs. detail namespace vs. private vs. creating pimpl or friend class. </p>
  
  <p>Here's my take.. Please let me know your thoughts. </p>
  
  <p>So, if I have 
    foo.hpp 
    foo.cpp</p>
  
  <p>and I have some free function <code>bar</code> that do not access any data members in <code>foo</code>, and furthermore no clients need to know those free functions and only <code>foo.cpp</code>'s method need them just directly put them in anon namespace in foo.cpp and be done with it. </p>
  
  <p>If however, <code>bar</code> needs access to foo's data members we can make <code>bar</code> private method of foo. But that means that even though foo's client don't really care about <code>bar</code>, everytime <code>bar</code> changes, we have a recompilation. </p>
  
  <p>(This part I am a bit fuzzy):
  However, atleast using a detail namespace in this case, helps readers of foo.hpp not to bother looking at <code>bar</code>, since they really don't need to know it.  Is this the general usecase for detail namespace convention? </p>
  
  <p>Now, if we have bunch of bar_1, bar_2...bar_n and they kind of relate together and they need access to data members , I can make a friend class <code>baz</code> to foo , and put the <code>bar</code>s there. </p>
  
  <p>If however, I am really concerned about compilation time and hiding the interface i can resort to pimpl (again very fuzzy on this part, usually if I see this, alarm bell goes off and tells me something is off in the design).</p>
  
  <p>Your thoughts... </p>