We propose a simple algebraic method for generating classes of traveling wave solutions for a variety of partial differential equations of current interest in nonlinear science. This procedure applies equally well to equations which may or may not be integrable. We illustrate the method with two distinct classes of models, one with solutions including compactons in a class of models inspired by the Rosenau-Hyman, Rosenau-Pikovsky and Rosenau-Hyman-Staley equations, and the other with solutions including peakons in a system which generalizes the Camassa-Holm, Degasperis-Procesi and Dullin-Gotwald-Holm equations. In both cases, we obtain new classes of solutions not studied before.