An embedded system is a special-purpose system that performs predefined tasks, usually with very specific requirements. Since the system is dedicated to a specific task, design engineers can optimize it by exploiting very specialized knowledge, deriving an optimally customized system. Low energy consumption and high performance are both valid optimization targets to increase the value and mobility of the final system. Traditionally, conceptual embedded software models are built irrespectively of the underlying hardware platform, whereas embedded-system specialists typically start their optimization crusade from the executable code. This practice results in suboptimal implementations on the embedded platform because at the source-code level not all the inefficiencies introduced at the modelling level can be removed. In this book chapter, we describe both novel UML transformations at the modelling level and C/C++ transformations at the software implementation level. The transformations at both design abstraction levels target the data types of dynamic embedded software applications and provide optimizations guided by the relevant cost factors. Using a real life case study, we show how our transformations result in significant improvement in memory footprint, performance and energy consumption with respect to the initial implementation. Moreover, thanks to our holistic approach, we are able to identify new and non-trivial solutions that could hardly be found with the traditional design methods.