Reading a field collection
The code above returns undefined variables/indexes on things that are obviously defined.


As long as your PHP installation is not buggy, that's not possible. If the variable is defined, PHP won't tell you it isn't defined.


  as soon as I refresh the page the errors go away which seems rather strange to me.


It's not strange - messages are held in the session so if you're doing something that invokes them in a template file (when the messages for the current page have already been prepared), you should expect to see this delayed reaction. Logic should never been in a template file, always a preprocess or process function.

Best practice is really a matter of opinion, but these are the two standard options for accessing fields on any entity type, Field Collection included.


field_get_items()
EntityMetadataWrapper


Both alleviate the need to access the arrays directly, thereby decreasing the possibility of developer error.