Ricardo's economic logic is essentially a precursor to optimization theories such as linear programming and the simplex method.
Don't be misled by his use of nations in his examples. David Ricardo was basicly an investment banker/stock broker who had little concern for what benefited either nation. His theory can be summarized as: "Maximize profits (the objective function) by minimizing inputs (the constraints -- labor, capital, etc.)" He did so by pitting one nation against each other to drive all inputs down to the commodity level.
It's a great theory for corporations engaged in transnational trade.
But that doesn't make it the best policy for a nation to pursue for the benefit of it's own citizenry. Actually, it's quite a darwinian abomination.