PBP: 075 Complex Mappings

The PBP suggests we factor complex map blocks into subroutines.  Please, please do this!

Part of my distaste for map is that I find reading them difficult.  Applying the block to the list just isn’t something that fits in my head well; I want to see the list first, then the block.  Breaking the block out into a subroutine makes it easier for me to stop and go understand the subroutine, then come back to the map and see that it’s doing that on this set.

The PBP points out, quite honestly, that blocks usually start simple and get hairier over time.  This is far too true.  Even I don’t think every block needs to be a subroutine.  The tipping point is hard to define, but an easy guideline might be that if you’re adding blocks inside the map block, maybe it should be a function.  This is a case we all need to use our good judgement, and may judge slightly differently.

Leave a Reply