Software often needs to be modified for accommodating requirements changes through the software life cycle. To deal with several accidental requirements changes related to software maintenance, a systematic and safe approach to modifying softwares is needed. The design patterns provide a high degree of design flexibility for such accidental requirements changes. In this paper, we propose an automated approach to refactoring based on design patterns in Java programs. In our approach, for a particular design pattern, we define an inference rule to automatically identify a set of candidate spots and a refactoring strategy to transform one of the set of candidate spots into the desired design pattern structure. A candidate spot may be a class or a set of classes to which the design patterns can be applied. We believe that our approach would be helpful to the maintainers in the sense that much of manual analysis on source code can be reduced, and the fashion of automated program transfo...