Where should I place hook_block_view_alter? this may be a trivial question, but I have no clue to how to get this working. I have this theme 'nexus'. When try the hook 

function nexus_preprocess_block(&amp;$variables) 


in the file nexus.theme, it works,

but function nexus_block_view_alter(&amp;$data, $block) 
doesn't.

Should I put it in a module? I tried creating a module using hello_world example, and put in the the module's controller but no avail.

Any hint would be much helpful.
In drupal 8 the declaration of hook_block_view_alter changed from hook_block_view_alter(&amp;$data, $block) (Drupal7) to  hook_block_view_alter(array &amp;$build, \Drupal\Core\Block\BlockPluginInterface $block) (Drupal 8).
For more info check hook_block_view_alter Documentation page.

hook_block_view_alter be better in custom module not theme, see guide to building basic Drupal 8 module, and flush all caches.