Never run/create Scala futures in the constructor of an object

I had a problem with a Scala Future example a couple of days ago, and Guillaume Martres helped me through it. He also mentioned one thing about Scala futures that I thought I should share here:

“Rule of thumb is: never run futures in the constructor of an object, this can easily lead to deadlock as you try calling a method of the object while the object is being initialized ... moving everything inside a main method is fine.”

I’ve seen that type of comment in other discussions related to the time required to create constructors, and when I saw what he wrote there it really hit home.