Computer Science 2 Revision Structure diagrams flowcharts Pseudocode

































- Slides: 33

Computer Science 2/ • Revision • Structure diagrams & flowcharts • Pseudocode & a basic algorithm • Arrays • UI/Wireframes Nationals 5

Development methodologies • When creating new software, software development teams need to work through different ‘phases’ • Certain tasks are performed at each phase • Q 1. What are the main phases of software development?

Iteration • Q 2. What does Iteration mean? • It means repeating a process. • In software development, it is used to describe repeating or revisiting phases that have been worked on already.

Agile! Iterative cycles • Traditionally • Development teams would work through each phase in order • Now? • More common for software to be developed in iterative cycles

Revisiting design • The Design for part of a program may be created and then Implemented • Errors found during Testing could lead to parts of the design and implementation changing before further testing: testing • The Design and Implementation phases could be revisited based on the results of testing

• Once one part of the program is complete, the iterative cycle of Design, Implementation and Testing could be repeated for the next part of the program! • Q 3. Can you now fill in the gaps here: “Errors found during _____could lead to parts of the design and implementation ______before_____” testing changing further testing

The Analysis phase • What two criteria does a systems analyst try to determine when they meet with the client? Budget and financial costs The functional requirements of the software (which specifies inputs, processes and outputs) The purpose of the software (a description of what the software will be used for) Revisiting phases that may have been worked on already Design and layout

Distinction between the purpose and functional requirements of software • Example 1 • Purpose • Software should be created to allow a user to enter ten numbers. • Each number must be validated to make sure that it is no less than 0 and no more than 100. • The program should keep a running total of the numbers entered and output the final total.

Functional requirements Inputs • Ten numbers Processes • Validate ten numbers • Calculate total Outputs • Final Total

Assumptions • It is also often necessary to clearly outline any assumptions that have been made prior to design and implementation. • Assumptions are often specific to the task at hand but generally take account of: • • the hardware needed to run the software any software compatibility concerns the need for an internet connection during use IT competency of the target user group • At the design phase, the purpose, functional requirements and any assumptions determined during analysis will be considered, and programmers will begin to develop a plan to create the software.

Design • At the design phase, programmers will consider the purpose and functional requirements identified during the analysis phase. • The functional requirements will be used to create a series of steps that can be converted to code during implementation. • It is necessary to be able to read, understand, describe and identify each of the following design techniques: • structure diagrams • flowcharts • Pseudocode • It is also necessary to be able to create the design for a given problem using one of the above techniques.

Structure diagrams • Structure diagrams are a visual design technique used to show the steps needed to solve a problem. • When reading a structure diagram start at the top and work towards the bottom. • If a level contains more than one branch, read from left to right before moving to the next level. • The following symbols are used:


• Pre-defined functions such as random, length and round will always return a single value. • If designing a solution that makes use of these functions, it is always necessary to use the pre-defined function symbol rather than the process symbol.

Analysis used to inform design • At the top of each structure diagram, it is necessary to define the general problem that is to be solved. • The programmer will consider the purpose and functional requirements that were established at the analysis phase. • Purpose: • Software should be created to allow a user to enter ten numbers. • Each number must be validated to make sure that it is no less than 0 and no more than 100. • The program should keep a running total of the numbers entered and output the final total.

Design using structure diagram • This structure diagram shows one approach to creating a design that is based upon the purpose and functional requirement. Purpose: • Software should be created to allow a user to enter ten numbers. • Each number must be validated to make sure that it is no less than 0 and no more than 100. • The program should keep a running total of the numbers entered and output the final total. Inputs • Ten numbers Processes • Validate ten numbers • Calculate total Outputs • Total

Alternative design for the same problem

Flowcharts • During the design phase, flowcharts can be used instead of structure diagrams. • Flowcharts are another example of a visual design technique.

Flowchart example • The programmer first considers the purpose and functional requirements established at the analysis phase. • Purpose • The owners of a theme park have asked that a program be developed to record the average number of visitors in a week. A user will enter the total number of visitors for each day of the week. The program should then output the average number of visitors across the week.

Functional requirements Inputs Processes Outputs Daily total Calculate average Average

Pseudocode • Pseudocode is a written design notation that is not based on any programming language. • It is not natural language like written English and it is not formal code used in high level languages. • Pseudocode allows a programmer to use indentation to clearly state the use of programming constructs such as iteration (loops) and selection statements (IF or CASE).

When creating pseudocode, it is important to remember: • To define the steps of the main algorithm • To refine the main steps where possible (not all main steps need to be refined) • That there is no need to declare variables • Indentation should be used to help identify use of loops and selection statements • Not to write steps using a formal language such as Visual Basic, True Basic, Live. Code, Python or Reference Language

Pseudocode example • The programmer will consider the purpose and functional requirements that were established at the analysis phase. • In this example, the information from the analysis phase is shown below to provide a context for the pseudocode examples that follow.

Analysis used to inform design • Purpose • A program is to be developed to create usernames for a class of twenty pupils • The program will ask a teacher to enter the first name, surname and age of each pupil. • The age entered must be between five and eighteen. • The program should output a list of usernames for the teacher. Functional requirements Inputs Pupil first name Pupil surname Pupil age Processes Validate age Create username Outputs List of usernames

Design using pseudocode Main steps (algorithim) 1 2 3 4 5 6 7 Initialise username Start fixed loop for twenty pupils Get first name and surname from user Get valid age from user Generate username Display "Username", index, "is" username End fixed loop

Refinement 3. 1 Get first name and store in first name array 3. 2 Get surname and store in surname array 4. 1 Get age and store in age array 4. 2 While age is less than 5 or higher than 18 start conditional loop 4. 3 Display error message "Invalid age, enter a number between 5 and 18 inclusive" 4. 4 Get age and store in age array 4. 5 End conditional loop 5. 1 Concatenate first name, surname and age and store in username array 5. 2 Start fixed loop from 0 to index -1 5. 3 If username equals stored username 5. 4 Add 1 to age 5. 5 Concatenate first name, surname and age and store in username array 5. 6 End If 5. 7 End fixed loop In the above example, the algorithm is designed in such a way that if a pupil has the same username as one already stored, the code will add one to their age and attempt to store the username again. The loop will repeat until the username generated is unique.



User interface (UI) design • The purpose and functional requirements generated during the analysis phase are also considered when designing a user interface. • A user interface is the part of software that the user sees and interacts with. • The user interface includes features that allow the user to input data and includes areas where the user will see on-screen output. • When designing user interfaces, it is common practice to create wireframes.

Wireframes • A wireframe is designed to provide a visual draft of how the interface could look. • A wireframe could be anything from a rough paper-based sketch to a full and detailed image. There are several online wireframe generators that make the process of creating wireframes easier. • Depending on the scale of the project, wireframes can be designed and then implemented by a programmer or by a specialist graphic designer. • Sometimes wireframes also contain notes or symbols to indicate that more information is needed or has to be considered prior to final implementation. • The purpose and functional requirements for a basic program are shown below to provide a context for the wireframe that follows.

Wireframe example

The wireframe shown above identifies the elements of the user interface that relate to the functional requirements. it can make implementation clearer for the programmer.

• The terms input, process and output and their associated arrows do not need to be implemented as part of the interface. • There are notes that need to be considered after design and prior to implementation • An agreed legend/key for identifying areas of the wireframe where this is relevant should also be established with the programmer and/or graphic designer.