Coding in a functional way

Alexandre Martinez, Civil and Environmental Engineering, University of California-Irvine

One challenges that I faced was that the students try to code directly on the computer with first thinking about what they need and they often either hit a wall of technical difficulties or end up copy-pasting their code a lot of time for some repetitive tasks instead of calling a function. These results in a non-efficient code, a student being sometimes lost in his code or making mistake in the calculation because he has too many lines of inconsistent code. It is specially true for civil engineers who didn't learn how to built an algorithms.

My strategy was to make them writing on paper first what they want to do using pseudo-code so they can realize that some parts which are similar can be gather under a function that they can call when they need. They also learn to use parameters and differenciate depending on their function so it is easier for them to make a small change with minimum effort instead of re-writing everything with different numbers.

Downloadable version of this essay