Dear community –
With the team, we just set up SonarCloud for code analysis of our firmware and source code. The tool is really useful and helped us drastically improve our code base!
One code smell that is often found is the use of
new. We usually make everything as static as possible, create objects before use, pass them as reference and avoid the use of
new as much as possible (side question: is this a good practice?).
This is the actual code smell:
The easy solution is the use of smart pointers:
Some of our code is based on mbed examples such as BLE that use
new. We’ve replaced it with the aforementioned solutions and it works great, the binary is just slightly bigger.
That being said, we are wondering is it’s good practice to use smart pointers for embedded development in general and with mbed in praticular?
Thanks for you help and feedback on this matter