[Effective-cpp] Item 35: Familiarize yourself with the langu age standard
Kevlin Henney
kevlin at curbralan.com
Fri Jun 13 05:08:05 EDT 2003
In message <7D5800A5B6E26644B2EB7A862856B0D4084832E9 at SARASWATI>,
Jaspreet Singh <Jasingh at quark.co.in> writes
> in the development projects that i've participated in (although
>few), i haven't used any templates and didn't find the need to use them.
That seems peculiar, perhaps you have missed an opportunity for
refactoring and reducing code duplication? I find that I need to define
or to use something already templated after only a few lines of code.
>ok..the classic swap example, or the one given below in the text can serve
>as a good reason to use them but practically i haven't come across such a
>situation... probably because the design was such that i bypassed this kind
>of a scenario. the ADT programming style is a bit different from the OO
>style
What do you mean by this? ADTs form the basis for both traditional OO
and generic programming: they share a common parent, and in modern OO
they are brought together.
>i think the "class T" is just a workaround for a parent "Object" class as in
>java.
Not quite: the reliance on a root Object to express genericity in a
statically typed language is a workaround for not having a proper
generics mechanism. Writing in any language that has a static type
system but lacks generics is tedious and error prone, as much Java code
demonstrates, and as C++ code from the early 1990s (at least in style,
if not in actual origin) demonstrated before templates became
widespread.
>a template can be used whenever we need a family of classes/functions... but
>i haven't come across such a situation.
I find that unlikely >:->
Kevlin
____________________________________________________________
Kevlin Henney phone: +44 117 942 2990
mailto:kevlin at curbralan.com mobile: +44 7801 073 508
http://www.curbralan.com fax: +44 870 052 2289
Curbralan: Consultancy + Training + Development + Review
____________________________________________________________
More information about the Effective-cpp
mailing list