Functional programming has become popular recently, and many object oriented languages (C#, Scala, Java) have begun including functional concepts as part of the language. Here we’ll go over a few functional ideas in C#.
In college, I had a physics class called Modeling and Simulation of Physics Systems in which students wrote code to model the physical behavior of various systems. The final project of the class involved choosing a system of interest, developing a model for it, and presenting the results with some sensatory aid.
Recently my team was given the opportunity to completely redo a particularly messy and troublesome piece of legacy C code, and as a team we decided to give MBSD a try. We had tried a few simple models before, all of which turned out to be more complicated than had we written the C code ourselves. But this time we were determined to do it right: we allocated plenty of time, received one-on-one training from the local MBSD guru, and reviewed the original requirements to ensure they met the needs of the system. Finally after exhausting all of the time, continually pestering the guru with questions and modifying the requirements several times, we succeeded in having a model based software design that actually worked the first time we tested it on the vehicle. It was a valuable experience overall and helped illustrate the drawbacks and benefits of MBSD over the typical C development.
While the Google Test framework is designed for C++ it can be used to create a framework for C unit testing. Reference the Google Test documentation for more details on the capabilities of Google Test.
These framework files are included in any C unit test project.
•A header file to define macros to interface from C++ to C – gtest_c.h
•A header file to provide C interfaces to the Google Test comparison functions – Gtest_helper.h.
•A helper file to interface Google Test comparison function to C – Gtest_helper.cc