Inconsistency naming convention

And another more technical post :] Today I had occasion to fix some functions in my rendering code. It was look somehow like this: 

struct GPUBuffer
    uint32 openGLBufferId;
    uint32 offset;
    uint32 size;


class CGraphicsManager
    /** @brief Create geometry buffer. */
    bool createBuffers( GPUBuffer* a_buffer,  uint32 a_sizeInBytes,  uint8* a_ptr,  bool a_dynamic);

    /** @brief Flush memory of geometry buffer. */
   void flushBuffer( const GPUBuffer& a_buffer,  uint32 a_offsetInBytes,  uint32 a_sizeInBytes, const uint8* a_ptr);
    /** @brief Destroy geometry buffer. */
    void destroyBuffers( GPUBuffer* a_buffer);

So nothing special but I seen here two inconsistency in code convention. First is that once I use pointers and in other occasions references I didn't thought a lot about this and changed everything on pointer. This was something natural to do for me but here came second problem : const .

Function flushBuffer don't change a_buffer in any way. It only use information that it contain to flush OpenGl constructions. So following most of articles and books that I remember, use of const is correct. But looking on purpose of this function it's somehow unnatural. Because even if a_buffer don't change inside function, object that is represented by it change. So in the end I removed const because I think that this way code is a more intuitive.

It's funny like such'a simple thing can force to so much thinking about code convention.


Popular posts from this blog

Query commands execution

Hierarchy - UI improvement

W.U. 0x20