I know that we're talking about 5E, but I want to mention how 3E "officially" did it, because it was such a big change from what I was used to (and I didn't think the 3E way worked at all). Many people ignored it, or didn't notice it, but in 3E, initiative was supposed to be thrown as soon as an enemy is perceived (usually seen). There's even an example in the DMG where the initiative count is kept through a closed door with orcs on the other side. In my game, I would wait further, until an actual attack was made. But, in 3E, if you read the rules, says to throw initiative when enemies are sighted. For me, this is wrong because it assumes every encounter will be a combat encounter. Players shouldn't have to fight every orc, every goblin. But, I guess that method served the wargaming-esque roots of 3E (encouraged to use miniatures and maps).