Monday, 7 June 2010

Moving away from OO

One of the pitfalls that OO coders fall into when doing data oriented development seems to be trying to access the outside world while stream processing. One thing that's come up numerous times on talks about components before has been getting the interoperability between components right. That was a problem when components were objects, but if you're thinking data oriented those issues go away.

In OO, if part A calls in part B, it can happen like this:

void partA::Tick()
/* some body */
if( this->SomeCondition() )
/* more body */

I've seen this in numerous places, from rendering systems to AI code.

in data oriented development, you can do this:

InputOutput( partA* ), Output( partBProcessRequest* ) -> Tick()
InputOutput( partB* ), Input( partBProcessRequest* ) -> Process()

Keeping the partB process requests this way, it's possible to use partB process requests to preload the cache with the right partBs so that processing doesn't stall, and you don't have the extra I cache miss of moving between scopes of doing the tick for partA and processing of partB.

No comments: