When to use Docker-Compose and when to use Docker-Swarm

My understanding is that Swarm overlay networks are now the way to connect containers. It’s made quite confusing because docker “stacks” use “compose” yaml files, and so it’s gets really confusing trying to work out what to put into the yaml compose file to get a swarm stack…