To help ensure that you grow perfect carrots there are several easy things you can try, including barriers, companion planting, raised growing and resistant varieties.
This isn't the most visually pleasing sight in the garden, so I prefer to create a carrot fly 'screen' by connecting the netting to canes which are at least 60cm (2ft) above soil level (think of it as a small windbreak). I state 60cm (2ft) as the female carrot fly is a low flying bug and they don't usually fly higher than this, so crops surrounded by the screen are typically unaffected if there are carrot flies present in your location.
As carrot flies are so little, butterfly netting is quite useless in protecting your roots from attack; you are better off utilising the more firmly woven Enviromesh or perhaps horticultural fleece. The simplest method to do this is to merely lay your picked netting over the spot where you've sown your seeds and bury, pin or weigh it down so that your carrots can grow however the flies can't get in. It is thought that carrot flies lay their eggs on the bare soil, so netting must be as near to the ground as possible.
In addition, for growing
Another way to utilise the 60cm (2ft) rule to your benefit is to grow in raised beds such as veg trugs, or containers raised on tables and walls. This works well for smaller-rooted ranges such as ball carrots like 'Rondo' or 'Paris Market'; even 'Chantenay' and 'Nantes' types can be grown like this as long as the container is around 30cm (1ft) deep offering enough space for roots to grow. I find that old containers (with holes in the bottom) work well on a wall, enabling you to grow different varieties in their bucket.