The ability to update or exchange the program code running on sensor nodes is a core requirement in many wireless sensor network scenarios. Such code update mechanisms must take the specific resource limitations of wireless sensor nodes into account since both the transmission and the processing of updates consume considerable amounts of time and energy. We present TinyModules, a novel code update mechanism for TinyOS-based sensor networks whose idea is to divide the program code into a static part and an exchangeable TinyModule. TinyModules is highly configurable with the system developer being able to freely define which parts of the application should be exchangeable. We show that the use of TinyModules can achieve considerable savings in terms of code update size and update time with only negligible additional processing required on the nodes.