Trial and error. A ton of trial and error, and a lot of guesses. More wrong than good guesses.
Basically every science field is based on this.