Serving the Quantitative Finance Community

  • 1
  • 7
  • 8
  • 9
  • 10
  • 11
 
User avatar
DominicConnor
Posts: 41
Joined: July 14th, 2002, 3:00 am

C++ virtual function cost

May 15th, 2011, 11:47 am

Any remarks on deep C++ inheritance hierarchies? (let's say 6 levels deep and of course the Publisher-Subscriber at the root). A developer's nightmare. I push the idea of visual determinacy AKA being able to tell what the code is going to do from what is on the screen, without having to page around and search too much.This thread started off on performance, and I have fouind there is a strong correlation between code that's easy to understand and how fast it goes.To some people that's not intuitive because we've all written something nasty that went quick.However when optimising code one has a finite budget of programmer time, and the longer you have to spend trying to work out what the code does, the less time you will have to make it go faster.Also since deep inheritence often has the purpose of hiding lower level detail it follows that you may easily miss serious optimisations.That's one reason why multiple inheritence may be a superior choice, since some teams code excessively deep hierachies because they want to remain singly inherited because some fuckwit coding standard (or manager) says they must. That's one reason I prefer C++ over Javan and C#Note I say may be a superior choice, when you pay me to code, you pay me to make good decisions about how I do it.I may decide that MI does the job, or I may not, but that choice needs to be mine.
 
User avatar
Cuchulainn
Posts: 23029
Joined: July 16th, 2004, 7:38 am

C++ virtual function cost

May 15th, 2011, 3:47 pm

QuoteThat's one reason why multiple inheritence may be a superior choice, since some teams code excessively deep hierachies because they want to remain singly inheritedIn beween these two options is to use SI and in combination with composition/delegation (HAS A).QuoteThis thread started off on performance, and I have fouind there is a strong correlation between code that's easy to understand and how fast it goes.A positive correlation, I hope
Last edited by Cuchulainn on May 15th, 2011, 10:00 pm, edited 1 time in total.