The Unified Modeling Language (UML) statechart diagram is a powerful tool for specifying the dynamic behavior of reactive objects. Generating code from statechart diagrams is a challenging task due to its dynamic nature and because many of the statechart concepts are not supported by the object oriented programming languages. Most of the approaches for implementing UML statecharts diagram either suffer from maintenance problems or implement only a subset of UML statecharts. This paper proposes a new approach to generate efficient and compact executable code from the UML statechart diagram in an object-oriented language like Java using design patterns. In our approach, each state in the statechart becomes a class, which encapsulates all the transitions and actions of the state. The events that have transitions are thus made explicit without using any if or case statement, which leads to a readable, compact and efficient code. The resultant code is easy to maintain. By representing states as objects, we extend the state design pattern to implement the sequential substates and concurrent substates using the concept of object composition and delegation. We also propose an approach to implement compound transitions (fork/join) and history nodes. The proposed approach makes elegant handling of most of the statechart features.