Showing posts with label Comments. Show all posts
Showing posts with label Comments. Show all posts

Monday, 8 September 2014

Lower Comments for Readability

The first thing that struck me was actually a really small things.. but one of those so intuitive things, it makes you wonder .. why did I never think of that, or how is it I have never come across this ?

Take a look at a snippet from one of their base classes .. what do you notice different?

namespace BloombergLP {

namespace bslma {

                        // ===============
                        // class Allocator
                        // ===============

class Allocator {
    // This protocol class provides a pure abstract interface and contract for
    // clients and suppliers of raw memory.  If the requested memory cannot be
    // returned; the contract requires that an 'std::bad_alloc' exception be
    // thrown.  Note that memory is guaranteed to be sufficiently aligned for
    // any object of the requested size on the current platform, which may be
    // less than the maximal alignment guarantee afforded by global
    // 'operator new'.

  public:
    // PUBLIC TYPES
    typedef bsls::Types::size_type size_type;
        // Alias for a signed integral type capable of representing the number
        // of bytes in this platform's virtual address space.


    // CREATORS
    virtual ~Allocator();
        // Destroy this allocator.  Note that the behavior of destroying an
        // allocator while memory is allocated from it is not specified.
        // (Unless you *know* that it is valid to do so, don't!)
        
    ...    
 }

Perhaps I have just been sheltered, but seeing the comments *below* the class name and method declarations.. is well just beautiful. It only stands to reason that I would like to know what is being commented on, before I read the comment.