To avoid supporting puppy farms (also known as puppy mills) you should only ever buy a puppy from a reliable source.
Your first stop for a new puppy should be a reputable animal rescue organisation (like the RSPCA) where there are many dogs in need of a good home. But if you don't find the right dog for you at a rescue shelter, you will need to find a responsible dog breeder so you can purchase a puppy from where it was born. In this way, you will be able to observe the parents (or at least the mother), the other breeding animals and puppies and ensure that the conditions in which they are kept are acceptable. You will also be able to talk to the breeder about the breed and its requirements, and observe how the animals are treated and how they respond to humans.
By making sure that the breeder takes good care of their animals before you purchase a puppy from them, you will be promoting responsible companion animal breeding and refusing to support commercial mass farming of puppies. Use our Smart Puppy Buyer's Guide to make sure you are buying from a reputable breeder.