Coconut barfi has a short ingredient list and a long list of ways to go wrong. The filling splits, the slab stays sticky, or it sets so hard it crumbles when you cut it. Almost every failure traces back to two decisions made before the mixture reaches the tray: the ratio of sugar to coconut, and how far the syrup was cooked before both were combined.
Understanding what each ingredient does in the pan makes the rest of the recipe easier to read and easier to repeat.