3. Functions - CS2030S Programming Methodology II
Another important abstraction provided by a programming language is the function (or procedure). This abstraction allows programmers to group a set of instructions and give it a name. The named set of instructions may take one or more variables as input parameters, and return one or more values. Like all other abstractions, defining functions allow us to think at a higher conceptual level. By composing functions at increasingly higher level of abstractions, we can build programs with increasing level of complexity. Functions help us deal with complexity in a few ways: Functions allow programmers to compartmentalize computation and its effects. We can isolate the complexity to within its body: the intermediate variables exists only as local variables that has no effect outside of the function. A function only interacts with the rest of the code through its parameters and return value, and so, reduces the dependencies between variables to these well-defined interactions. Such compartment
Unit 3: Functions After reading this unit, students should understand the importance of function as a programming constructor and how it helps to reduce complexity and mitigate bugs. be aware of two different roles a programmer can play: the implementer and the client understand the concept of abstraction barrier as a wall between the client and the implementer, including in the context of a function. Function as an Abstraction over Computation Another important abstraction provided by a programming language is the function (or procedure). This abstraction allows programmers to group a…
saved by
related reading
- 4. Encapsulation - CS2030S Programming Methodology IInus-cs2030s.github.io
- Critically Conscious Computing: Methods for Secondary Educationcriticallyconsciouscomputing.org
- Essays on programming I think about a lot | benkuhn.netbenkuhn.net
- how I think when I think about programming - alice mazalicemaz.com
- Abstraction (computer science) - Wikipediaen.wikipedia.org
- Structure and Interpretation of Computer Programsmitp-content-server.mit.edu
- The Law of Leaky Abstractions – Joel on Softwarejoelonsoftware.com
- Up and Down the Ladder of Abstractionworrydream.com
- A practical introduction to functional programmingmaryrosecook.com
- An introduction to functional programmingcodewords.recurse.com
- Structure and Interpretation of Computer Programsmitp-content-server.mit.edu
- Repeat yourself, do more than one thing, and... — programming is terribleprogrammingisterrible.com