mreddington opened a new pull request #925:
URL: https://github.com/apache/geode-native/pull/925


   The idea is to begin raising the level of abstraction in implementation 
code. The only thing a `for` loop tells you is there's a loop, and you are left 
to deduce the intent of the loop in what is usually already a large function. 
Algorithms give names to loops and remove the pedantic details of the actual 
loop construct. In some instances, a range-for might appear to be more concise 
code, if it's only 2 (short) lines, but it still doesn't name the algorithm. If 
the code has gotten a little ugly, then I suggest helper functions that name 
the intent of the returned lambda and does the capture:
   
   ```
   auto do_the_work(type &param_to_capture) {
       return [&param_to_capture](std::shared_pointer<Cacheable> &thing) { 
/*body*/ };
   }
   ```
   
   So that the uglier algorithm code can look a little cleaner:
   
   ```
   std::for_each(std::begin(v), std::end(v), do_the_work(context));
   ```
   
   I posit we could replace nearly every loop in the NC with algorithms, as 
almost all of what happens is indeed either straight looping across a range, 
generating, or copying.
   
   Finally, with C++11, we get execution policies, which means where available, 
we can execute in an unsequenced order and let the STL suss out the details. It 
would at the very least express that particular part of the code has more 
liberty than usual.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@geode.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to