Visas can be categorized in 2 very basic ways: visas in advance and visas on arrival.
Many countries, such as China, Brazil, Russia, India, Cameroon and Kenya, require that you have a visa in advance before you are allowed to enter. For these countries, no visa means no trip. In this case, the choice is simple: you must get your visa before you go.