专业英语W7:functions
All of you should have some experience with functions. Tell me about your experience - When do you choose to use functions? When do you choose not to use functions?
I came across the notion of functions was at C class the first time. At that time, I was told by my teacher to packet some related sentenses together to achieve some functionality. By its name, I thought function was a tool and began a little puzzled about the difference between functions in programming and in Maths.But at this time, I think that both “function” in either Computer or Maths is taking input and producing output.
After dealing with more programming languages, including typical OOP language C++ or Java, or Python and PHP, which is scripting language, I have known more about Functions. Firstly, Functions mainly act as the method(interface) of the object or component of the overall programme with different functions. They may be used to achieve separate function, which helps to the modularity. There are many well-defined library functions which pack a bunch of related functions. For instance, the “libc” is often used to interact with system and the terminal. For myself, I can also pack some functions to form my own library. Secondly ,function is good for automation and reducing redundancy in Code, such use often comes up with scripting languages.
But function is not always good. I may not use function when there are extra costs to call a function such as too much memory is occupied, especailly in some compiler languages. Another bad case is when I was about to write a function to derive some substring from a string, I put in the” src string “and made its substring as a return value, which led to the error of returning a temparory address. From this experience, I gradually drop my habbit of using function all the time and tend to use function more carefully especially in simple situations.