OOP and DOD methodologies

Started by
10 comments, last by Finalspace 6 years, 1 month ago

Regarding the difference between OOP and DOP i made a sample n-body particle simulation a while ago, to see the actual differences in maintenability and performance. I tried that by making the same application in 4 different code-styles:

- Naive, poorly OOP without thinking about hardware at all (Most software is written in this style!)

- Still OOP but a bit more thinking, but not that hard

- Still OOP but with performance and cache in mind

- DOP but poorly implemented

 

But this experiment had a few problems:

- It has a lot of shared code (App handling, Math, Multithreading, Rendering etc.) which was equal on all 4 code-styles, so the differences can only be seen in some areas (Neighbor search for example).

- The DOP approach is just poorly implemented, i am pretty sure this can be done much better - so this thing need a fifth style: Good DOP!

- A SPH fluid simulation may not be the best scenario for that experiment

 

Why did i create this?

First of all to see it for myself. Is there actually a difference and how strong are that? How good is the compiler at optimizing?

But more importantly i wanted to make this to show people that naive poorly written OOP may be really bad for performance.

 

My result:

The compiler is pretty good at optimizing the obvious things, such as optimizing getter and setters out, inlining code, eliminate branches etc.

So some OOP concepts makes no difference between POP and/or DOP style. Removing virtual functions is unneccesary when you just call it a few times per frame - but makes a difference when you call it ten-thousands times per frame.

 

If one is interested and wants to try it out yourself or wants me to help me writing the fifth style:

https://github.com/f1nalspace/nbodysimulation_experiment

This topic is closed to new replies.

Advertisement