A shape design optimization problem for viscous flows has been investigated in the present study. An analytical shape design sensitivity expression has been derived for a general integral functional by using the adjoint variable method and the material derivative concept of optimization. A channel flow problem with a backward facing step and adversely moving boundary wall is taken as an example. The shape profile of the expansion step, represented by a fourth-degree polynomial, is optimized in order to minimize the total viscous dissipation in the flow field. Numerical discretizations of the primary (flow) and adjoint problems are achieved by using the Galerkin FEM method. A balancing upwinding technique is also used in the equations. Numerical results are provided in various graphical forms at relatively low Reynolds numbers. It is concluded that the proposed general method of solution for shape design optimization problems is applicable to physical systems described by nonlinear equations.