This paper presents a rational theory of cognitive strategy selection and change in which the cognitive agent in consideration is proposed to be adaptive in choosing the "best" or optimal strategy from a set of strategies available to be employed. The optimal strategy is assumed to maximize the difference between the expected utility of the goal which the selected strategy would lead to and the computational cost associated with achieving this goal. We considered an example of strategy selection and change in computer programming and interpreted the results from a set of experimental studies we had conducted in this domain in the light of this rational framework. W e also substantiated our theoretical claims by developing a computer simulation of this example. The simulation was implemented in ACTR, a cognitive model constrained by rational analysis as well as by experimental data.