[Clam-devel] style

Dirk Griffioen dirk.griffioen at barcelonamedia.org
Mon May 25 09:29:40 PDT 2009


Hi All,

I know there is a coding guideline and discussing style is very
dangerous :), but if I may, I would like to share some thoughts on what
I read; the following line is from the OfflineNetworkPlayer.cxx file.


for(std::vector<SndfileHandle*>::iterator it=infiles.begin();it!
=infiles.end();it++) delete *it;


- please dont type everything as if it was one big word, use proper
spacing like when writing text: source is meant to be read by humans
(computers dont read)

- please type ++i instead of i++:  http://www.parashift.com/c
++-faq-lite/operator-overloading.html#faq-13.15

- please dont put multiple statements on 1 line (return or delete after
if for instance): debuggers cant set breakpoints


- use typedefs, its shorter, more clear as it expresses what you're
doing and localizes the 'type', when you change it, you only need to
change one place

    for(SndFileHandles::iterator it = infiles.begin(); it !=
infiles.end(); ++it) 
        {
        delete *it;
        }

- please note: with the use of smartpointers, this whole line becomes
obsolete as they and their resources are destructed when the vector is

- please do not indent in namespaces: c++ is not java or c#


What is the lists opinion?

Dirk

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.clam-project.org/pipermail/clam-devel-clam-project.org/attachments/20090525/bb526f4e/attachment-0003.htm>


More information about the clam-devel mailing list