# Code Separation Using Blocks January 24, 2011

This is a short blog entry to describe how you can use blocks to seperate a generic code from problem specific using blocks. Those that have been looking at Project Euler might recognize this problem description.

The program is supposed to calculate the sum of all even-valued Fibonacci numbers that doesnâ€™t exceed a `STOP_VALUE`.

To keep the Fibonacci calculations generic I wanted to separate the problem specific logic from the code calculating the Fibonacci sequence. Blocks can be really helpful for that which is shown below.

This method accepts a block that is called for every Fibonacci number in the sequence until the blocks sets the `stop` flag. The problem specific code is then placed inside the block.