> -------Original Message------- > From: Hisham Ahmed <[email protected]> > To: [email protected] <[email protected]> > Subject: [freedom] Purpose of using generics > Sent: 2023-06-16 01:42 > > Dears, > > My question is do you recommend always using generics? or if it's sometimes > required and sometimes not? > Also, what is the guideline for that? I believe it's a big topic and I'm > not sure how to accomplish it. >
Beyond simple toy examples, any code that you write will make use of facility from the standard library (C++ or any other language). As a result, an application programmer will use libstdc++ or Generics. Having said that, in reasonly well designed application software, one will see patterns of abstraction across 'Types' and 'Algorithms'. In that case, the implementation will need to be Generic for both code clarity and to avoid code duplication. The guideline is starting with a specific type and implement the design. When you encounter related types showing pattern, you have a candidate for Template / Generics. That's when you RE-factor the codebase and bring in the Generic types. Hope this helps everyone see it as 'Software Engineering' powered by Abstract Algebra. warm regards Saifi.
