Using Ptolemy II as an exemplar modeling environment, this report explores the challenges and problems that exist for model-based code generation. The report describes a reusable code generation framework built using two simple design patterns, code template and adapter, that are well-suited for an actor-based environment. The extensible infrastructure helps simplify the process for future experiments, especially for new models of computation (MoCs). The report tackles the challenges posed by configurable higher-order actors. It also demonstrates a system for incorporating multiple datatypes and specializing polymorphic functions to increase code efficiency.