Please enable JavaScript.
Coggle requires JavaScript to display documents.
Thinking Ahead (Examples of reusable program components (print(), Turtle()…
Thinking Ahead
-
Preconditions
If an algorithm requires a number bigger than one to work, you need to make sure the program tests for a number bigger than one so it does not crash.
Advantages
-
If there are no preconditions, the user can be sure the subroutine will do the checks itself, stopping unnecessary coding
-
Input
Is the information relative to the problem which could for example be passed as parameters to a subroutine
-
-
Explain the benefits of specifying inputs, outputs and preconditions for a subroutine which will be saved in a library of subroutines for importing into many programs.
When writing a program, it is beneficial to the user to specify your input, output and precondition. Specifying these ensures the user knows what checks must be carried out before calling the subroutine If there are no preconditions, the user can be sure the subroutine will do the checks itself, stopping unnecessary coding It also makes the subroutine reusable and means it can be put into a library of subroutines which can be imported in order to solve problems.
London Trip
-
-
-
-
-
If you are going into London, you need to know what the factors are that would affect the trip.
Coding
Another example. If you are writing a program for a company, you cannot just set off and write the program. You need to know certain details
-
-
-
-