Code defensively when creating object