2.6.1: understand the benefits of using subprograms and be able to write code that uses user-written and pre-existing (builtin, library) subprograms
Keyword | Definition |
---|---|
Abstraction | hiding unnecessary detail to focus on what's important. You don't need to know the detail of how a subprogram works in order to use it. |
Builtin subprogram | a procedure or function that can be used 'out of the box' (e.g. print() in python). This means common tasks are easy achieve with very little code |
Call | make a subprogram run |
Decomposition | splitting a big problem into smaller sections. Different programmers can work on separate subprograms. |
Definition | the lines of code that say exactly what a subprogram should do |
Function | a subprogram that can be used more than once to calculate and return a value. It has a name which should describe what it does |
Identifier | the name of a subprogram that should describe what it does in order to make code more readable |
Library subprogram | a procedure or function that can be used if imported into your program. This saves programmers having to re-invent the wheel for every project |
Procedure | a subprogram that can be used more than once to do something useful. It has a name which should describe what it does |
Reuse | subprograms can be defined once but called many times |
Subprogram | a section of code that has a name. It can be used more than once (e.g. procedure or function) |
User-written subprogram | a procedure or function that you write yourself. This can be reused in the same or other projects. |