Phobos classes member declaration order

Alexander aldem+dmars at nk7.net
Fri May 13 14:26:53 PDT 2011


On 13.05.2011 23:07, Jonathan M Davis wrote:

> I believe that the two most common practices when declaring member variables 
> is either to put them all at the top of the class declaration or all at the 
> bottom. If they're private (as is usually the case), I much prefer to put them 
> at the bottom.

  Could you please tell me, why you put them at the bottom? I just want to understand why declarations at the bottom are better than at the top... especially when it makes search difficult when working with someone else code...

  For instance, talking about core.thread, it took me some time to find the type of m_addr (I am digging for some mysterious segfault in Thread.priority), as this member is used quite often, so search, of course, took some time.

  Given the size of this code, even finding class bottom was a problem. Sure, there are some IDE's or editors which can point you exactly to declaration, but none are available for Linux in text mode, AFAIK...

/Alexander


More information about the Digitalmars-d mailing list