There is no definite answer to this question. That's why you should think about all the pros and cons before making a final decision.
Define your goals
First of all, it is important to understand why you're actually getting a dog. Do you want a lovely companion, sports activities partner, "a working force" for a particular aim or a friend for your kids?
You should also be clear in advance with how much time you are ready to dedicate to your pet. Can you spend some extra time apart from walking or training, for example, for solving behavioral problems, if there are any?
Answers to those questions will help you make the right decision.
Would a puppy from a kennel be a trouble-free puppy?
Many potential owners think that purchasing a puppy from a kennel is a guarantee of quality. However, kennels are really different.
There are kennels where the dogs are kept in crates all the time and haven't got enough communication with people. There are countryside kennels where the dogs are kept only in the backyard and don't see anything else. And there are kennels with very caring breeders who ensure that their puppy discovers the world in all its diversity.
The first two types are not very different from the best dog shelters. So there's no guarantee that a purebred dog from such a kennel will meet your expectations. Moreover, there are high chances that your dog will have troubles with socialization and much time will have to be spent correcting the problem behavior.
Besides, puppies from the same litter may have totally different temperaments. A breeder from a good kennel will help to choose a puppy which suits you best. And if the kennel is not a good one, it is very unlikely that the breeder will help to make the right choice.
That's why, if you need a companion or a sports activity partner and you are ready to devote enough time to it, you can get a puppy from a kennel where it has had insufficient interaction with people and the environment. However, in this case, the age of the puppy should not exceed 4-5 weeks as at this age you'll be able to compensate for the missing experience. But in this case, you may as well get a puppy from a shelter.
If you plan to have children or you already have them, it is recommended not to get a shelter puppy or a puppy from a kennel with poor environment diversification. You'd be better to focus on getting an adult dog with the temperament you need or buying a puppy (preferably older than 3 months) from a good kennel where a breeder cares much about their pets' well-being.
If you need a dog for a particular activity (a goal-oriented work or sports) it is recommended to address a good kennel that specializes in breeding such dogs. In all other cases the chances for disappointment are rather high.
And what if you rescue a stray puppy off the streets?
As a rule, puppies raised on the streets have no communication with people or have few experiences and usually unpleasant ones. That's why there's a great risk that you'll fail to socialize such a dog. Or it will take a lot of effort to make such a dog feel comfortable in a human environment.
If you have made a final decision to take a stray puppy, pick up a little one at the age of 1-2.5 months. In this case, there is a chance that such a pup hasn't had much negative experience and it will be easier for you to socialize it and fit it into people's lives.
Of course, you can get an older puppy or even an adult dog but only if you are ready to put much time and effort into its adaptation. You should understand and take into account all the possible risks.
And, of course, it is very unlikely you'll find a sports or working dog in the streets.
However, no matter where you take the puppy from, education and training are of the greatest importance. The thing is one way is simpler and another is quite thorny. Every case has its own merits. And sometimes, it is the dog from the street which becomes one's best friend.
One thing you should know for sure is that making a decision is fully your responsibility. Not a single dog asks be brought into your house and no dog is obliged to meet your expectations. An Akita inu is not necessarily Hachiko and a German shepherd, even from the best kennel, may not become an "Inspector Rex."