Designing algorithms for a solution
First, decompositionThe breaking down of a system into smaller parts that are easier to understand, program and maintain. the problem and use abstractionThe process of separating and filtering out ideas and specific details that are not needed in order to concentrate on those that are needed. to provide clear algorithms to meet the needs of the user or solve problems.
If we look at the sample task, we can determine that there are many problems needing to be solved in order to create the overall solution. We can use abstraction to break down the complexity.
Start by identifying the simplest problem to solve. Create a list that will be your success criteria for solving the task. At this stage, think about the solution in terms of modules, or 'separate bits'. This will allow you to determine the degree to which you can separate the components and recombine them later.
The easiest module to write for the sample problem is a functionA section of code that, when programming, can be called by another part of the program with the purpose of returning one single value. to capture the user's name.
Once identified, you can start listing your success criteria.
For example:
The solution will include a function to capture a user's name as a stringA sequence of characters often stored as a variable in a computer program. These characters can include numbers, letters and symbols. , use length checkchecks that data isn't too short or too long. and presence checkchecks that data has been entered or exists. checks to validate the name, and return the name variable.
One of the more complex abstractions from the sample is to search and retrieve a record from the file from disk. This may involve identifying a few success criteria. For example:
A linear search function A function designed to search for the presence of an item stored within an array, database or list. will be created to search the certificate file for individual student’s certificate and return the results to the screen.
- The function will accept student surname as an input
- The function will print their name, level and score on screen
Success criteria
You should create a clear list or table of all the success criteria that you will attempt to design and implement. For example:
| Success criteria | |
| 1. | The solution will include a function to capture a user's name as a string, use length and presence checks to validate the name, and return the name variable for use later in the program. |
| 2. | A main menu will greet the user with a personalised message and ask at which level they want to be tested (Easy, Medium, Hard). |
| 3. | Four functions will be created that will add, subtract, multiply and divide integer value. The function will accept two numbers as arguments and return the result after the mathematical operation |
| ... | |
| 15. | A linear search function will be created to search the certificate file for each individual student's certificate and return the results to the screen. The function will accept student surname as an argument and will print their name, level and score on screen. |
| 1. | |
|---|---|
| Success criteria | The solution will include a function to capture a user's name as a string, use length and presence checks to validate the name, and return the name variable for use later in the program. |
| 2. | |
|---|---|
| Success criteria | A main menu will greet the user with a personalised message and ask at which level they want to be tested (Easy, Medium, Hard). |
| 3. | |
|---|---|
| Success criteria | Four functions will be created that will add, subtract, multiply and divide integer value. The function will accept two numbers as arguments and return the result after the mathematical operation |
| ... |
|---|
| 15. | |
|---|---|
| Success criteria | A linear search function will be created to search the certificate file for each individual student's certificate and return the results to the screen. The function will accept student surname as an argument and will print their name, level and score on screen. |