[Gllug] C++ Templates, Opinions?
Bruce Richardson
itsbruce at uklinux.net
Fri Dec 17 11:35:15 UTC 2004
On Thu, Dec 16, 2004 at 11:01:37PM +0000, Ian wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi Folks,
>
> I was just wondering what people though about using function/class
> templates in C++, To me it looks clever but like it could drastically
> reduce the readability of C++ code (ie find a func call, go looking for
> it in code, cant find it directly etc)
In OO languages that lack a templating/preprocessing feature,
programmers can fall into a habit of using inheritance to improve
readability and maintainability in places where it is not appropriate.
Even where this does not have an impact on performance (by postponing to
runtime things that could otherwise have been resolved at compile-time),
it creates cumbersome and artificial dependency heirarchies.
Using C++ templates is effectively like using a sophisticated
preprocessor. This means that templates can allow you to avoid this
trap but still have code reuse.
OTOH, templates are overused by former C-coders who don't really
undestand OO and think it's all just a clever preprocessor hack.
Then agaoin, there are some interesting things you can do with
templates: http://en.wikipedia.org/wiki/Template_metaprogramming
--
Bruce
If the universe were simple enough to be understood, we would be too
simple to understand it.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 261 bytes
Desc: Digital signature
URL: <http://mailman.lug.org.uk/pipermail/gllug/attachments/20041217/52346baa/attachment.pgp>
-------------- next part --------------
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list