How can the idea of precondtioning as part of 'Thinking Ahead' benefit a programmer when writing code?

'Thinking Ahead' is one of 5 main aspects of Computational Thinking. It is the planning of inputs, ouputs and preconditions that the program will adhear to. By 'Thinking Ahead' programmers can discover how the program will work before coding it. The aim for most programs in Computer Science is reusability - nobody wants to have to program the same x lines hundreds of times! So 'Thinking Ahead' allows the programmer to decide on the form of the inputs and outputs, such as the data type, the size, if certain inputs are blacklisted, etc (the details form this are then noted down in comments for the code). In doing so the programmer can assume that all inputs into the module are in the form they defined and as such no logic errors will occur. This leads to a big benifit - once preconditions are defined the programmer doesn't need to code checks for the intputs, saving time and space in code. Once the program has defined preconditions the internal working of the code becomes irrelavent, as all that needs to be known is what is does (not how it does it) and how the inputs and outputs must be formed. Now the program can be used in any situation by any level of programmer. For example: When you need to get an integer as an input from a text box you initially have the input as a string. To convert this to an integer, a function similar to integer() is called. This is a modular function that has already been written, with a complexity above most people programming ability, but it can be used by anyone as the input type has been predefined as anything and the output as an integer. So the programmer knows what to expect from the function.

Answered by Nathan H. Computing tutor

8451 Views

See similar Computing A Level tutors

Related Computing A Level answers

All answers ▸

Explain how a stack could be used in the process of evaluating an expression in Reverse Polish notation.


What are the different development methodologies and what are their advantages and disadvantages?


What is the time complexity of Bubble Sort?


One member of a chess club sends a text file saved in Unicode. What meant by the term "Unicode" and why might this be necessary?


We're here to help

contact us iconContact usWhatsapp logoMessage us on Whatsapptelephone icon+44 (0) 203 773 6020
Facebook logoInstagram logoLinkedIn logo

© MyTutorWeb Ltd 2013–2024

Terms & Conditions|Privacy Policy