[Clam-devel] refactoring backends (3)

David García Garzón dgarcia at iua.upf.edu
Mon Jun 8 10:10:09 PDT 2009

On Monday 08 June 2009 17:44:01 dirk.griffioen wrote:
> Hi,
> I would very much like to take out duplicate code, a good example of
> what I mean is:
> the only difference is the container, the rest code is the same.
> So for instance the registerports function will boil down to 1 function:
> Same goes for all the explicit loops, I would prefer std::for_each (or
> BOOST_FOREACH) for that matter:
> as for me this separates the loop (not interesting) from the blanking
> code; but it can be argued that this last remark is trivial
> My question then is
> - is removing duplicate code by adding template code like the above
> liked as refactoring?
> - is std::for_each liked?

No doubt it is. Feel free to use anything on the standard stl. Just balance 
duplicate code, efficiency and understandability as you feel, no need to say. 
If duplicate code harms maintanibility, so does 'clever' constructs. (CLAM is 
full of those, but we learned the leason.)

Also, please, when talking about code, better to paste code to the list than 
sending screenshots. They are more big, and they are lost in the replies.


More information about the clam-devel mailing list