Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 292003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:08:25+00:00 2026-05-12T06:08:25+00:00

I have to make a decision regarding generalization vs polymorphism. Well the scenario is

  • 0

I have to make a decision regarding generalization vs polymorphism.

Well the scenario is standard: I want to make my monolithic interdependent
code to be more modular, clean and extensible.
It is still in a stage where the change of design principle is doable,
and, as I look at it, highly desirable.

Will I introduce purely virtual base classes (interfaces) or templates?

I am aware of the basics regarding the template option:
less indirection, better performance, more compiling
but
no late binding, and so on.

The stl does not use much (or none?) inheritance, and boost doesn’t either.
But I think those are aimed to be really small basic tools that are used every
2 lines of code by the programmer.

I consider the inheritance and late binding approach to be more sensible for
plug-in style of big pieces of code and functionality that should be interchangeable,
updateable etc. after deployment or even during runtime.

Well my scenario lies somewhat inbetween.

I dont need to exchange pieces of code on the fly at runtime, compile time is fine.
Usually it is also a very central and frequently used piece of functionality,
it is not logically seperatable into big blocks.

This lets me tend somewhat to the template solution.
To me it also looks somewhat cleaner.

Are there any big bad implications, are interfaces still THE way
to go? When are they not?
Which complies more with standard c++ style?

I know this is bordering on subjective, but I am really interested in
some experiences. I don’t own a copy of Scott Meyers effective C++
so I set my hopes on you guys 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T06:08:26+00:00Added an answer on May 12, 2026 at 6:08 am

    You’re basically right, dynamic polymorphism (inheritance, virtuals) is generally the right choice when the type should be allowed to change at runtime (for example in plugin architectures). Static polymorphism (templates) is a better choice if the type should only change at compile-time.

    The only potential downsides to templates are that 1) they generally have to be defined in the headers (which means more code gets #included), and this often leads to slower compile-times.

    But design-wise, I can’t see any problems in using templates when possible.

    Which complies more with standard c++
    style?

    Depends on what “standard C++ style” is. The C++ standard library uses a bit of everything. The STL uses templates for everything, the slightly older IOStreams library uses inheritance and virtual functions, and the library functions inherited from C uses neither, of course.

    These days, templates are by far the most popular choice though, and I’d have to say that is the most “standard” approach.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 178k
  • Answers 178k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer From memory JWindow's do not receive focus/window events. May 12, 2026 at 3:43 pm
  • Editorial Team
    Editorial Team added an answer In Vim 7.2, you can set the suffixesadd to .txt… May 12, 2026 at 3:43 pm
  • Editorial Team
    Editorial Team added an answer ^[A-Za-z]$ May 12, 2026 at 3:43 pm

Related Questions

I am struggling to make a decision regarding the correct organisation for a web
I have never used virtualization, and am trying to get up to speed. My
I'm currently in the process of setting my website, largely with php. Though this
I have a decision to make and I'm kicking it to the stackoverflow community.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.