Course: Computing Science Software Design and Development Units Level: National 4/5 April 2013 This advice and guidance has been produced for teachers and other staff who provide learning, teaching and support as learners work towards qualifications. These materials have been designed to assist teachers and others with the delivery of programmes of learning within the new qualifications framework. These support materials, which are neither prescriptive nor exhaustive, provide suggestions on approaches to teaching and learning which will promote development of the necessary knowledge, understanding and skills. Staff are encouraged to draw on these materials, and existing materials, to develop their own programmes of learning which are appropriate to the needs of learners within their own context. Staff should also refer to the course and unit specifications and support notes which have been issued by the Scottish Qualifications Authority. http://www.sqa.org.uk Acknowledgements © Crown copyright 2013. You may re-use this information (excluding logos) free of charge in any format or medium, under the terms of the Open Government Licence. To view this licence, visit http://www.nationalarchives.gov.uk/doc/open-governmentlicence/ or e-mail: psi@nationalarchives.gsi.gov.uk. Where we have identified any third party copyright information you will need to obtain permission from the copyright holders concerned. Any enquiries regarding this document/publication should be sent to us at enquiries@educationscotland.gov.uk. This document is also available from our website at www.educationscotland.gov.uk. 2 SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 Contents Introduction ..................................................................................................... 4 Approaches to learning, teaching and assessment ......................................... 8 Subject content ............................................................................................. 13 Staff notes ................................................................................................ 15 Advice on practical evidence .................................................................... 18 Introduction .............................................................................................. 23 Data representation .................................................................................. 23 Computer architecture .............................................................................. 28 Programming languages .......................................................................... 31 Designing a program ................................................................................ 36 Writing programs ...................................................................................... 38 Programming constructs ........................................................................... 42 Errors in programs .................................................................................... 46 Glossary ................................................................................................... 50 Qualifications ............................................................................................ 55 SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 3 INTRODUCTION Introduction This resource provides advice and guidance for staff delivering Software Design and Development units at National 4 and 5. Before embarking on these units, staff should be familiar with the contents of the technologies principles and practice paper: http://www.educationscotland.gov.uk/learningteachingandassessment/curricul umareas/technologies/index.asp Staff should also read the computing science professional focus paper produced by Education Scotland to ensure that they have familiarised themselves with the key areas of significant change and potential approaches to teaching and learning. http://www.educationscotland.gov.uk/nationalqualifications/professionalfocusp apers/index.asp?bFilter=1&bSortCD=0&11_subjecttopics=New National Qualifications\|Technologies\|Computing Science (NQ subject) The general unit information that follows has been taken, summarised and adapted from the Computing Science National 4 and 5 course support notes. 4 SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 INTRODUCTION Guidance for staff Key skills, knowledge and understanding A broad overview of the subject skills, knowledge and understanding that will be assessed in the Software Design and Development unit is given below. Mandatory skills and knowledge National 4 Applying, with guidance, aspects of computational thinking across a range of straightforward contexts. Applying aspects of computational thinking across a range of contexts. Designing, implementing and testing, with guidance, digital solutions (including computer programs) to straightforward problems across a range of contemporary contexts. Designing, implementing and testing, digital solutions (including computer programs) to problems across a range of contemporary contexts Developing skills in computer programming and the ability to communicate how a program works by being able to read and interpret code. Communicating basic understanding of key concepts related to software design and development clearly and concisely using appropriate terminology. Communicating understanding of key concepts related to software design and development clearly and concisely using appropriate terminology. Basic knowledge of the impact of contemporary technologies on the environment and society. Applying computing science concepts and techniques to create solutions across a range of contexts. National 5 SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 5 INTRODUCTION Links to prior learning Entry to this unit is at the discretion of the centre. However, learners would normally be expected to have attained some relevant skills and knowledge through prior experience. Skills and knowledge developed through any of the following, while not mandatory, are likely to be helpful as a basis for further learning for this course. Other SQA qualifications For National 4: Computing Science National 3 or relevant component units Numeracy National 3. For National 5: Computing Science National 4 or relevant component units Numeracy National 4. Experiences and outcomes In this course, any of the following Experiences and Outcomes may be relevant. Having investigated a current trend of technological advance in Scotland or beyond, I can debate the short- and long-term possibilities of the technological development becoming a reality. (TCH 4-01a) I can debate the possible future impact of new and emerging technologies on economic prosperity and the environment. (TCH 4-01c) By discussing the business, environmental, ethical and social implications of computer technology, I can begin to gain an understanding of the need for sustainability and accessibility. (TCH 4-05a) I can compare different forms of security software to gain knowledge and understanding of their functions in protecting contemporary technologies. (TCH 4-08b) I can integrate different media to create a digital solution which allows interaction and collaboration with others. (TCH 4-08c) 6 SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 INTRODUCTION Through research, I can gain knowledge of computer systems or emerging technologies to understand their differing features and consider their suitability for the world of work. (TCH 4-08d) By learning the basic principles of a programming language or control technology, I can design a solution to a scenario, implement it and evaluate its success. (TCH 4-09a) I can create graphics and animations using appropriate software which utilise my skills and knowledge of the application. (TCH 4-09b) I can use features of software to create my own animation which can then be used to create an animated sequence. (TCH 4-09c) Progression from this unit From National 4 progression may be possible to: Computing Science National 5 National Certificate Group Awards in computing, IT and related disciplines other technological courses at National 4 employment, apprenticeships and/or training in IT and related fields. From National 5 progression may be possible to: Higher Computing Science National Certificate Group Awards in computing, IT and related disciplines other technological courses at National 5 employment, apprenticeships and/or training in IT and related fields. Ultimately, for some, progression may be possible to: Advanced Higher Computing Science a range of computing-related Higher National Diplomas (HNDs) degrees in computing, IT and related disciplines careers in computing, IT and related disciplines. SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 7 APPROACHES TO LEARNING, TEACHING AND ASSESSMENT Approaches to learning, teaching and assessment Computing Science, like all new and revised national courses, has been developed to reflect Curriculum for Excellence values, purposes and principles. The approach to learning and teaching developed by individual centres should reflect these principles. Learners should be encouraged to participate fully in active learning and practical activities by working together, talking, listening, reading or reflecting on a topic while staff act as a facilitator. An appropriate balance of teaching methodologies should be used in the delivery of the course and a variety of active learning approaches is encouraged, including the following. Activity-based learning Whole-class, direct teaching opportunities should be balanced by activitybased learning and practical tasks. An investigatory approach is encouraged, with learners actively involved in developing their skills, knowledge and understanding by investigating a range of real-life and relevant problems and solutions related to areas of study. Learning should be supported by appropriate practical activities, so that skills are developed simultaneously with knowledge and understanding. Group work Practical activities and investigations lend themselves to group work, and this should be encouraged. Working within a group will encourage learners to collaborate and work co-operatively with others. Learners engaged in groupwork strategies capitalise on one another’s knowledge, resources and skills in questioning, investigating, evaluating and presenting ideas to one another. While working as a team is not specifically identified as one of the skills for life, learning and work for this course, and therefore is not assessed, it is a fundamental aspect of working in the IT and related industries and so should be encouraged and developed by staff. 8 SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 APPROACHES TO LEARNING, TEACHING AND ASSESSMENT Problem-based learning Problem-based learning (PBL) is another strategy that will support a learner’s progress through this course. This method may be best utilised at the end of an outcome or a topic where additional challenge is required to ensure learners are secure in their knowledge and understanding, and to develop the ability to apply knowledge and skills in less familiar contexts. Learning through PBL develops a learner’s problem-solving, decision-making, investigative, creative thinking, team working and evaluative skills. Computational thinking Computational thinking is recognised as a key skill set for all 21st-century learners – whether they intend to continue with computing science or not. It involves a set of problem-solving skills and techniques used by software developers to write programs. There are various ways of defining computational thinking. One useful structure is to group these problem-solving skills and techniques under five broad headings: Abstraction: seeing a problem and its solution at many levels of detail and generalising the information that is necessary. Abstraction allows us to represent an idea or a process in general terms (eg variables) so that we can use it to solve other problems that are similar in nature. Algorithms: the ability to develop a step-by-step strategy for solving a problem. Algorithm design is often based on the decomposition of a problem and the identification of patterns that help to solve the problem. In computing science as well as in mathematics, algorithms are often written abstractly, utilising variables in place of specific numbers. Decomposition: breaking down a task so that we can clearly explain a process to another person – or to a computer. Decomposing a problem frequently leads to pattern recognition and generalisation/abstraction, and thus the ability to design an algorithm. Pattern recognition: the ability to notice similarities or common differences that will help us make predictions or lead us to shortcuts. Pattern recognition is frequently the basis for solving problems and designing algorithms. Generalisation: realising that a solution to one problem may be used to solve a whole range of related problems. Underpinning all of these concepts is the idea that computers are deterministic: they do exactly what you tell them to do. The corollary of this, of course, is that they can be understood. SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 9 APPROACHES TO LEARNING, TEACHING AND ASSESSMENT Whilst computational thinking can be a component of many subjects, computing science is particularly well-placed to deliver it. Staff are encouraged to emphasise, exemplify and make these aspects of computational thinking explicit (at an appropriate level) wherever there are opportunities to do so throughout the teaching and learning of this course and its units. Using online and outside resources Throughout the teaching of this course, the stimulation of learners’ interest and curiosity should be a prime objective. Engagement with outside agencies or industry professionals can greatly enhance the learning process. Online resources, such as those listed in the individual unit support notes, may provide a valuable addition to teaching and learning activities, encouraging research, collation and storage of information and evaluation of these materials. The use of interactive multimedia learning resources, online quizzes and web-based software can also be used to support activity-based approaches. Assessment activities, used to support learning, may be usefully blended with learning activities throughout the course, for example by: sharing learning intentions/success criteria using assessment information to set learning targets and next steps adapting teaching and learning activities based on assessment information boosting learners’ confidence by providing supportive feedback encouraging self- and peer-assessment techniques wherever appropriate. Working towards units and course Learning and teaching activities should be designed to develop: skills and knowledge to the standard required by each unit and to the level defined by the associated outcomes and assessment standards the ability to apply the breadth of knowledge, understanding and skills required to complete the Added Value Unit at National 4 or the course assessment at National 5 successfully. 10 SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 APPROACHES TO LEARNING, TEACHING AND ASSESSMENT Meeting the needs of all learners Within any class, each learner will have individual strengths and areas for improvement. For example, within a National 4 class, there may be learners capable of achieving National 5 standards in some aspects of the course. Where possible, they should be given the opportunity to do so. Staff need to consider both the outcomes and assessment standards, and the table of content in Appendix 2 of the SQA unit support notes, to identify the differences between National 4 and National 5. In some aspects of the course the difference between National 4 and National 5 is defined in terms of a higher level of skill. For example, in the Information System Design and Development unit, Outcome 1 requires National 4 learners to ‘develop simple information systems using appropriate development tools’, by creating a structure with links, integrating different media types and identifying and rectifying errors, while at National 5 in the similar Outcome 1 learners are also required to create a user interface and write or edit simple code. In other aspects of the course, the difference between National 4 and National 5 is defined by additional or more in-depth knowledge. For example, in the Software Design and Development unit, National 4 learners need to report on a contemporary software-based application, while National 5 learners need to compare two different software languages or environments. When delivering this course to a group of learners, with some learners working towards National 4 and others towards National 5, it may be useful for staff to identify activities covering common knowledge and skills for all learners, and additional activities for National 5 learners. This is particularly appropriate where the National 5 learners have come directly from the Broad General Education without previously studying National 4. Where National 5 learners have studied National 4 in a previous year, it is important to provide them with new and different contexts for learning to avoid de-motivation. Learning about Scotland and Scottish culture will enrich the learners' learning experience and help them to develop the skills for learning, life and work they will need to prepare them for taking their place in a diverse, inclusive and participative Scotland and beyond. Where there are opportunities to contextualise approaches to learning and teaching to Scottish contexts, staff should consider this. SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 11 APPROACHES TO LEARNING, TEACHING AND ASSESSMENT Gathering evidence Assessment should be an ongoing process that permeates effective learning and teaching. Staff are encouraged throughout the Curriculum for Excellence documentation to adopt imaginative and creative approaches to assessment that take account of learners’ experience in terms of challenge, breadth and application. Staff should refer to the principles of assessment as laid out in Building the Curriculum 5: http://www.educationscotland.gov.uk/thecurriculum/howdoyoubuildyourcurricul um/curriculumplanning/whatisbuildingyourcurriculum/btc/btc5.asp For unit assessment purposes, a variety of methods of assessment should be used to gather a rich range of evidence such as creation of media, written work, role-play and oral presentations. More detail on gathering evidence can be found on the SQA secure website in the unit assessment support notes for National 4 and 5. Staff should share learning and assessment criteria with learners, provide effective feedback, encourage peer- and self-assessment and use effective questioning techniques. 12 SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 SUBJECT CONTENT Subject content Below is a table summarising the content for the Software Design and Development unit taken from the Computing Science National 4 and 5 course support notes: Software Design and Development Exemplification and implementation of the following in an application development environment Topic National 4 National 5 Computational constructs Exemplification and implementation of the following constructs: expressions to assign values to variables expressions to return values using arithmetic operations (+, -, *, /, ^) execution of lines of code in sequence demonstrating input – process – output use of selection constructs including simple conditional statements iteration using fixed and conditional loops String Numeric (integer) variables Exemplification and implementation of the following constructs: expressions to assign values to variables expressions to return values using arithmetic operations (+, -, *, /, ^) use of selection constructs including simple and complex conditional statements and logical operators (AND, OR, NOT) iteration using fixed and conditional loops pre-defined functions String Numeric (integer and real). variables Boolean variables 1D arrays Normal, extreme and exceptional test data Syntax, execution and logic errors in programs Readability of code (internal commentary, meaningful identifiers, indentation) Data types and structures Testing and documenting solutions Normal, extreme and exceptional test data Readability of code (internal commentary, meaningful variable names) SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 13 SUBJECT CONTENT Algorithm specification Design notations (for both software development and information system development) Low-level operations and computer architecture Input validation Contemporary design notations. Graphical to illustrate selection and iteration. Contemporary design notations Pseudocode to exemplify programming constructs Use of binary to represent and store: positive integers characters instructions (machine code) Translation of high-level program code to binary (machine code): interpreters and compilers Use of binary to represent and store: integers and real numbers characters instructions (machine code) graphics (bit-mapped and vector) Units of storage (bit, byte, Kb, Mb, Gb, Tb, Pb) Basic computer architecture: processor, memory, buses, interfaces 14 SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 SUBJECT CONTENT Staff notes The main purpose of this text is to provide a single document with the basic theory for the Software Design and Development unit. It does not provide a step-by-step practical guide in a particular programming language on how to cover the practical parts of the unit because there are a variety of excellent resources available already for this purpose. The unit assessment support notes for Computing Science National 4 and 5 provide examples of the sort of work learners are expected to be doing to prove that they are working at the correct level. The section below breaks down the core programming skills required in the National 4 and 5 courses and directs staff to some excellent resources that cover the skills required in a particular programming language. The list is by no means exhaustive and there are new documents and guides being shared everyday on the CAS forum (http://community.computingatschool.org.uk/), which is an excellent community for computing staff to share ideas and resources. Useful websites A short and by no means exhaustive list of useful computing websites. Back issues of Computer & Information Sciences & Engineering newsletters http://www.nsf.gov/cise/csbytes/pastissues.jsp Computer Science Unplugged http://csunplugged.org/activities The Roles of Variables home page http://www.cs.joensuu.fi/~saja/var_roles/ Wikibooks on the topic of computing http://en.wikibooks.org/wiki/Subject:Computing Peer Instruction for Computer Science http://www.peerinstruction4cs.org/ A site which allows staff to create free games, quizzes, activities and diagrams http://www.classtools.net/ BBC site with a collection of excellent video clips to illustrate course theory with real-life examples http://www.bbc.co.uk/learningzone/clips/ SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 15 SUBJECT CONTENT Harvard’s main page of resources for the Scratch programming environment http://cs.harvard.edu/malan/scratch/index.php Computer Science for Fun magazine http://www.cs4fn.org/teachers/activities/ Online interactive tool for learning programming http://www.codecademy.com/#!/exercises/0 National forum for computing staff to support one another and share resources, experiences and ideas http://community.computingatschool.org.uk/ Home page for Education Scotland computing resources and documentation http://www.educationscotland.gov.uk/nationalqualifications/subjects/computing .asp Recommended books Below are some books that may help learners and staff in aspects of the Computing Science National 4 and 5 courses. Beginning Programming For Dummies (paperback), Wallace Wang. ISBN-13: 978-0470088708 Higher Computing (paperback), John Walsh. ISBN-13: 978-0340905630 How to Pass Intermediate 2 Computing (paperback), Frank Frame ISBN-13: 978-1444108361 How to Pass Standard Grade Computing (paperback), Frank Frame. ISBN-13: 978-0340973912 Information Systems for You: Student's Book (paperback), Stephen Doyle. ISBN-13: 978-0748763672 Megabyte (paperback), Simon Cotton, Graham Teager and Robert Austin. ISBN-13: 978-0198328254 Pathways to Excellence: Level 3: Computing and ICT (paperback), Frank Frame and John Mason. ISBN-13: 978-1444110791 Pathways to Excellence: Level 4: Computing and ICT (paperback), Frank Frame and John Mason. ISBN-13: 978-1444110807 16 SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 SUBJECT CONTENT PCs For Dummies (paperback), Dan Gookin. ISBN-13: 978-0470465424 Raspberry Pi User Guide (paperback), Eben Upton and Gareth Halfacree. ISBN-13: 978-1118464465 Scratch Programming for Teens (paperback), Jerry Ford, Jr. ISBN-13: 9781598635362 Standard Grade Computing Studies (paperback), John Walsh. ISBN-13: 9780340885000 The BCS Glossary of IT and Computing Terms (paperback), BCS British Computer Society. ISBN-13: 978-0131479579 The Game Maker's Apprentice (paperback), Jacob Habgood and Mark Overmars. ISBN-13: 978-1430213475 Visual Basic 6 For Dummies (paperback), Wallace Wang. ISBN-13: 9780764503702 Other resources There are other digital resources which at time of writing are available for Intermediate 1/2 Computing and Standard Grade and could provide additional exercises and theory for the Computing Science National 4 and 5 courses. These are listed below: Softplanet Intermediate 2 and Standard Grade http://www.softplanetgroup.com/study-software/businesscomputing/intermediate-2-computing http://www.softplanetgroup.com/study-software/business-computing/standardgrade-computing Webcal Intermediate 1/2 and Standard Grade http://www.webcal.esmartbiz.com/prod0405.htm Exercises and content To reduce the costs of reprographics and allow differentiation in a multi-level class, National 4 and 5 content is included in the same document. National 5 exercises are in bold and National 5 content is highlighted using shaded blocks. SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 17 SUBJECT CONTENT Advice on practical evidence The following section outlines the practical tasks learners are expected to attempt during the unit and gives suggestions as to documents that might aid staff in delivering these experiences. National 4 Exemplars of assessment and learner responses in SQA Unit Assessment Support: Software Design and Development (National 4) Package 1: Unit-byunit approach 1 Explain how simple programs work, drawing on understanding of basic concepts in software development by: 1.1 Reading and explaining code Exemplar questions in Software Design and Development (National 4) Package 1: Unit-by-unit approach, pp27–29. 1.2 Describing the purpose of a range of programming constructs and how they work (The range of programming constructs should include expressions, sequence, selection and iteration.) Exemplar questions in Software Design and Development (National 4) Package 1: Unit-by-unit approach, pp27–29. 1.3 Explaining how data and instructions are stored Exemplar questions in Software Design and Development (National 4) Package 1: Unit-by-unit approach, pp27–29. 2 Develop short programs using a software development environment by: 2.1 Selecting and using expressions, sequence, selection and iteration Iteration (repetition) p 34 Computing Science Mobile App Development Advice for Practitioners (using AppInventor) MoleMasher Game. Selection (if statements) p 39 Computing Science Mobile App Development Advice for Practitioners (using AppInventor) TimesTable helper. 18 SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 SUBJECT CONTENT Iteration (fixed and conditional loops) p 46 Computing Science Mobile App Development Advice for Practitioners (using AppInventor) HeadsIWin. Computing Software Development [INTERMEDIATE 2] David Bethune Expressions pp58–68, Sequence pp67–72, Selection pp85–101 Repetition/Iteration pp102–133. 2.2 Selecting and using appropriate simple data types, such as numeric (integer) and string Variables integer and string p 27 Computing Science Mobile App Development Advice for Practitioners (using AppInventor) FingerPaint Variables integer pp53–61 Computing Software Development [INTERMEDIATE 2]David Bethune Strings pp38–46 Computing Software Development [INTERMEDIATE 2]David Bethune 2.3 Testing digital solutions using supplied test data Testing p29 Computing Science Mobile App Development Advice for Practitioners (using AppInventor) FingerPaint etc. Computing Software Development [INTERMEDIATE 2]David Bethune pp53– 59 2.4 Identifying and rectifying errors in programs p39 Computing Science Mobile App Development Advice for Practitioners (using AppInventor) TimesTable helper pp110–112 Computing Software Development [INTERMEDIATE 2]David Bethune Programs should include at least one construct and one data type. 3 Produce a short factual report on a contemporary software-based application by: 3.1 Describing the application Exemplar report in Software Design and Development (National 4) Package 1: Unit-by-unit approach, pp17–20. SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 19 SUBJECT CONTENT 3.2 Explaining how its features relate to programming constructs and data types. Exemplar report in Software Design and Development (National 4) Package 1: Unit-by-unit approach, pp17–20. 3.3 Describing its impact on the environment or society Exemplar report in Software Design and Development (National 4) Package 1: Unit-by-unit approach, pp17–20. National 5 1 Explain how programs work, drawing on understanding of concepts in software development and basic computer architecture by: 1.1 Reading and explaining code Exemplar questions in Software Design and Development (National 5) Package 1: Unit-by-unit approach, pp25–28. 1.2 Describing the purpose of a range of programming constructs and how they work Exemplar questions in Software Design and Development (National 5) Package 1: Unit-by-unit approach, pp25–28. 1.3 Describing the purpose and role of variables Exemplar questions in Software Design and Development (National 5) Package 1: Unit-by-unit approach, pp25–28. 1.4 Describing in simple terms how programs relate to low-level operations and structures Exemplar questions in Software Design and Development (National 5) Package 1: Unit-by-unit approach, p29. The range of programming constructs should include expressions, sequence, selection, iteration and pre-defined functions. 20 SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 SUBJECT CONTENT 2 Develop short programs using one or more software development environments by: 2.1 Selecting and using a combination of expressions, sequence, selection, iteration and pre-defined functions Various examples in Computing Software Development [INTERMEDIATE 2]David Bethune Expressions pp58–68, Sequence pp67–72, Selection pp85– 101 Repetition/Iteration pp102–133, Pre-defined functions pp64–66 & 72–83. Exemplar programs tasks in Software Design and Development (National 5) Package 1: Unit-by-unit approach, pp31–33. 2.2 Selecting and using appropriate simple data types, such as numeric (integer and real), string and Boolean Variables integer and string p29 Computing Science Mobile App Development Advice for Practitioners (using AppInventor) Computing Software Development [INTERMEDIATE 2]David Bethune, pp50– 52. Variables Boolean p39 Computing Science Mobile App Development Advice for Practitioners (using AppInventor). Exemplar programs tasks in Software Design and Development (National 5) Package 1: Unit-by-unit approach, pp31–33. 2.3 Testing digital solutions using own test data Testing p29 Computing Science Mobile App Development Advice for Practitioners (using AppInventor) Computing Software Development [INTERMEDIATE 2]David Bethune, p59. Exemplar programs tasks in Software Design and Development (National 5) Package 1: Unit-by-unit approach, pp31–33. 2.4 Identifying and rectifying errors in programs p39 Computing Science Mobile App Development Advice for Practitioners (using AppInventor) TimesTable helper. SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 21 SUBJECT CONTENT pp110–112 Computing Software Development [INTERMEDIATE 2]David Bethune 2.5 Providing internal commentary or documentation pp42 and 45–46 Computing Software Development [INTERMEDIATE 2]David Bethune Exemplar programs tasks in Software Design and Development (National 5) Package 1: Unit-by-unit approach, pp31–33. Programs should include at least two constructs and at least two data types. 3 Produce a short detailed report comparing two contemporary software development languages or environments by: 3.1 Describing how each represents standard constructs Exemplar report in Software Design and Development (National 5) Package 1: Unit-by-unit approach, pp17–18. 3.2 Comparing the range of data types provided Exemplar report in Software Design and Development (National 5) Package 1: Unit-by-unit approach, pp17–18. 3.3 Comparing their editing features Exemplar report in Software Design and Development (National 5) Package 1: Unit-by-unit approach, pp17–18. 3.4 Describing how high-level code is translated and executed Exemplar report in Software Design and Development (National 5) Package 1: Unit-by-unit approach, pp17–18. 22 SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 SUBJECT CONTENT Introduction Computers are just expensive paperweights if no-one tells them what to do. To be useful, a computer needs instructions. These instructions or commands come in two sorts: 1. 2. A program you write yourself telling the computer what to do in a stepby-step list. A program that someone else has written for you which you buy. Either way, to get a computer to do what you want, it needs programs. Programs follow a set format: they generally take in some sort of input, perform some kind of action or process and then produce an output. Using a game (type of program) as an example, the game takes input in the form of key presses, mouse clicks or gamepad movements. The game then processes the information, for example how far to move a character on screen, and the output is the character actually moving on the screen. Game Input Process Output Key presses, mouse clicks or gamepad movements Deciding how far to move a character on screen Character actually moving on the screen Programming is about giving a computer the tools and instructions to solve a problem. To solve a big problem you generally take a top-down approach and break the big problem down into smaller chunks to make it more manageable. Data representation Units of storage Bit is short for binary digit and is the smallest unit of measurement on a computer having either the value 0 or 1. Memory is measured by the byte, and a byte can store a single character. An example of this is that the word ‘egg’ is three characters long and therefore requires 3 bytes of computer memory storage. Modern PCs require billions of bytes to simply load up the operating SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 23 SUBJECT CONTENT system, so to make these huge quantities of bytes easier to refer to, there are a number of terms to describe them. Name Short form Byte Kilobyte Megabyte Gigabyte KB MB GB Terabyte TB Petabyte PB Precise amount 8 bits 1024 bytes 1024 kilobytes or 1,048,576 bytes 1024 megabytes or 1,073,741,824 bytes 1024 gigabytes or 1,099,511,627,776 bytes 1024 terabytes or 1,125,899,906,842,624 bytes Approximate amount 8 bits 1 thousand bytes 1 million bytes 1 billion bytes 1 trillion bytes 1 quadrillion bytes Storing numbers Computers count in twos (ones and zeros) this is called binary and contrasts with the way humans count, which is in decimal. Power of 2 Decimal value Decimal number 67 (64 + 2 + 1) 27 26 25 24 23 22 21 20 128 64 32 16 8 4 2 1 0 1 0 0 0 0 1 1 Very large numbers are stored using floating point representation. An example of this is that the number 987654321 would be shown as 0.987654321 × 109. The 0.987654321 is called the mantissa and the 9 is the exponent. Storing text The group of letters, numbers and characters that the computer can work with is called the character set. At this level of study the character set discussed is ASCII, which consists of: Letters both upper case and lower case Symbols Non-printing or control characters Numbers 24 A–Z, a–z &, *, %, $ <tab>, <escape>, <return> 0–9 SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 SUBJECT CONTENT One byte is used to store a single character, for example the ASCII code for an upper case ‘A’ is 65 in decimal or 01000001 in binary. Storing graphics Graphics can be stored in either bitmap or vector format. In a bitmap graphic each pixel or point on the screen is represented by a binary number, with an empty dot being represented by a 0 and a filled dot represented by a 1. Images are then built up from a grid of these pixels or picture elements. 1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 1 0 0 1 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1 0 0 0 0 0 1 0 0 1 0 0 0 1 0 0 0 0 1 0 1 0 0 0 0 0 0 1 With vector or object-oriented graphics the picture is stored in a mathematical format with a list of object attributes such as x- and y-coordinates, line width, length, breadth etc. SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 25 SUBJECT CONTENT Exercises 1. 1 terabyte is the same as: A 1024 gigabytes B 1024 megabytes C 1000 megabytes D 1024 bytes 2. The number 23 represented in binary is: A 10111000 B 00000111 C 00010111 D 11101000 3. The binary number 00101001 is what in decimal? A 82 B 41 C 148 D 255 4. ASCII can be described as what? A A 16 bit code used to store graphics. B A 7 bit code used to store graphics. C A 16 bit code used to store characters. D A 7 bit code used to store characters. 5. A black and white graphic, 30 pixels by 20 pixels in size, stored as a bit map, would require how much storage? A 600 bytes B 600 KB C 600 bits D 50 bits 6. Each character on the keyboard has its own ASCII code. The ASCII code for one of the control characters is 13. (a) Convert the decimal number 13 into a binary number. (b) Describe the function of ‘control characters’. 7. How much storage space is required to store a black and white image that is 4 inches long and 3 inches tall at a resolution of 200 dpi? Give your answer in kilobytes and show all your working. 8. A bit-mapped image measures 11 by 8 inches at 600 dpi in 24-bit colour. Calculate the file size of the uncompressed image. Show all your working and give your answer in MB. 26 SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 SUBJECT CONTENT 9. Explain the meaning of the term 'resolution' when referring to a bitmapped image. 10. What is the relationship between resolution and file size in a bitmapped graphic? 11. Using a bitmapped graphics package create a portrait of your learning partner or neighbour and save the file. After completing the portrait in a bitmapped package try to recreate a similar portrait using a vector drawing package and save the file. Compare the file size of the two portraits. Which takes up the most disk space and why? 12. Complete the bit map for the 8 × 8 image below. 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 1 1 0 1 1 1 1 0 1 1 0 1 0 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 1 1 1 0 1 1 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 13. Calculate the storage requirements for the above image. 14. Create your own image and complete a bit map for your image. 15. A program calculates average rainfall for a week. An example of the results for one week is 19.6 mm. Describe how floating point representation is used to represent this real number. SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 27 SUBJECT CONTENT Computer architecture Processor The central processing unit (CPU) is essentially the brains of the computer, organising the computer's inputs, processes and outputs. The CPU takes in the data that is input to the computer, processes it and then outputs it to, for example, a printer or monitor. Examples of this are illustrated in the table below. Input Process Output Entering values into a spreadsheet A character for a computer game is drawn using a graphics tablet Product details are entered into a database Calculating the average value Graphic is resized Printing the results Products are sorted on price in ascending order from cheapest to most expensive Graphic is saved to a USB memory stick Results displayed on screen The CPU consists of three main parts: arithmetic and logic unit (ALU) control unit registers. The control unit sends out control signals to execute instructions, eg to store data in memory, to read data from memory and to decode and carry out instructions. The ALU carries out both arithmetic and logic tasks. Arithmetic functions include tasks such as addition, subtraction, multiplication and division. Logic functions enable the computer to make decisions, for example by comparing values using operators such as >, <, =, if and else. Registers are small, temporary memory locations on the actual processor itself used to store data, instructions and memory addresses, and retrieve them immediately. 28 SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 SUBJECT CONTENT Memory There are two categories of memory: main memory and backing storage. Backing storage is for the permanent storage of a user’s data and applications on devices like hard disks and pen drives. Main memory is the memory inside the computer itself. Main memory on a computer is divided into random access memory (RAM) and read-only memory (ROM). RAM holds data and programs as they are being used by the processor – data can be exchanged and updated quickly but is lost when the power is switched off. ROM is used to hold essential core programs and data and therefore cannot be changed and does not lose its contents when the power goes off. Buses In simple terms buses are the wires that connect the processors to the memory and devices attached to the computer. There are a number of different kinds of buses and they can be unidirectional (only allow data to go one way) or bidirectional (allow signals to go in both directions). More is learned about the various types of buses and their functions in Higher Computing. Interfaces When talking about computer architecture the interface is the technology (both hardware and software) that lets the processor communicate with the hardware devices (peripherals) connected to it. Interfaces are the ‘middle man’ between the computer and the device, making up for things like differences in speed, signal and voltage between them and carrying status messages such as when a printer is out of paper. More is learned about the various types of buses and their functions in Higher Computing. SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 29 SUBJECT CONTENT Exercises 1. The main parts of a processor are: A RAM, ROM and registers B input devices, output devices and backing storage C control unit, ALU and registers D main memory, backing storage and registers 2. What is the purpose of a computer processor? 3. Draw a four-box diagram representing the main components of a computer system. 4. What is the name of the part of the processor that is responsible for the timing of operations? 5. What is the name of the part of the processor that carries out calculations and makes logical decisions? 6. If a document is in RAM and power is suddenly lost, what would happen to the document? 7. A printer is connected to a computer using an interface. Describe one function of an interface. 8. A computer system makes use of both main memory and backing storage. Explain the difference between these. 9. State one feature of RAM that differs from ROM. 10. What is the name given to the wires that connect the processor to the memory and devices attached to the computer 30 SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 SUBJECT CONTENT Programming languages Low-level languages Computers are two-state machines made up of many electronic switches that are either off or on. This is represented by 0 for off and 1 for on, and this system called binary or machine language. A program written in machine language might look like this: 1101 1010 1100 0000 0011 0101 0101 0011 1101 0011 1110 0001 To write a program only using 1s and 0s is difficult, as it is easy to make mistakes and it takes a long time to write. To make programming easier something called assembly language was invented, which uses short phrases like MOV and JMP instead of lines of 1s and 0s. Although these phrases or mnemonics are easier for humans to read, understand and write in, they still have drawbacks, for example it is difficult to transfer programs from one type of computer to another (something called portability) and the programs are still time-consuming to write. Given these drawbacks, programming languages closer to the English language have been developed. These languages, which use English-like phrases such as print, do, if, then and else, are called highlevel languages. High-level languages Advantages of high-level languages: allow programs to be written much faster than in assembly language quicker to learn than machine or assembly language reading, fixing and changing high-level language code is easier than for lower level code high-level language programs can run on a number of different computers (they are more portable). There are a wide variety of high-level languages available, each with pros and cons, and each suited to solving a particular type of problem. Depending on what type of computer a programmer wants to control or what type of problem a programmer wants to solve, a programmer picks a specific type of programming language for the job. Compilers and interpreters Once the program has been written in a high-level language using an editor, it might make sense to a human but, as mentioned earlier, computers only understand 1s and 0s. To fix this, a program is required to translate the source SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 31 SUBJECT CONTENT code into machine code. There are two types of program to do this translation: interpreters and compilers. Interpreters convert each line of code one line at a time. This translation is only temporary and every time the program is run it has to be interpreted again. Compilers take the programmer’s source code and convert it in one go; these machine code instructions are stored in another file called an executable. This conversion only has to happen once unless the source code is updated. Comparing programming languages Programming languages can be categorised according to functions or features. A small selection of common categories is shown in the table below: Category Web page Scripting Database Rapid application development 32 Description Allows the programmer to create interesting, interactive web pages rather than just plain text on a screen Allows the programmer to customise an existing program with added functionality or an altered user interface Allows the programmer to write code that makes storing, retrieving and printing information from a database more convenient Allows the programmer to create programs with a graphical user interface quickly. Example Java Visual Basic for Applications (VBA) Structured Query Language (SQL) Visual Basic SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 SUBJECT CONTENT At this level of study you will be asked to research and write a report comparing two different modern programming languages. The table below gives a quick example comparison of two programming languages: Purpose Visual Basic 6.0 Allows programmers to make Microsoft Windows applications Key features Designed to be easy to learn Programmers can create graphical user interface applications Programming Visual basic combines visually placing components or controls on a form, setting attributes and actions for these components, and then writing extra lines of code Interface Use of variables Graphical Three main types: string, numeric (byte, currency, double, integer, long, and single) and special (Boolean, date, object and variant) Use of constructs Allows loops (repetition) such as ‘do...while’ and ‘for…next’ and decisionmaking (selection), such as ‘if …then...else…’ Scratch 1.4 Allows programmers to make interactive stories, animations, games, music and art Projects contain scripts and media Sounds and pictures can be imported or authored in scratch using a sound recorder and paint tool Programs are created by snapping together coloured command blocks to control 2D graphical objects called sprites moving on a background called the stage Projects can then be saved to be run later in scratch or uploaded and shared on the scratch website Graphical Strings for displaying text on screen or making decisions Numeric (whole numbers of real numbers) for things like movement, musical notes or decision making Allows loops (repetition) with blocks such as ‘forever’ and decisionmaking (selection) such as ‘if …else…’ SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 33 SUBJECT CONTENT Impact on environment or society 34 BASIC means ‘beginners' all-purpose cymbolic instruction code’ Compared to many other commercial programming languages it is easy to learn The code uses English language constructs and allows less experienced programmers to create limited but effective programs quickly, even if the solutions are not as neat or efficient as more powerful as languages such as C++ Scratch is an excellent introduction for learners to take their first steps into programming as it is colourful and involves very little typing and no complicated syntax or programming rules Software is freeware, with a huge online community providing advice, encouragement and forums to share achievements Scratch allows programmers to expand into physical computing using Lego WeDo and Pico boards, allowing programs to interact with the outside world SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 SUBJECT CONTENT Exercises 1. Machine code: A is easier to understand than high-level language code B uses normal English words C needs to be translated before it can be executed D does not need to be translated before it is executed 2. A program which translates an entire high-level language program into a machine code file is: A a compiler B an interpreter C a text editor D an algorithm 3. A program which translates high-level language code into machine code, running each line as soon as it is translated is: A a compiler B a text editor C an interpreter D an algorithm 4. Translators are required to translate high-level language programs into machine code. Which type of translator translates the whole program before any execution takes place? 5. What type of programming language would be most suitable for automating a complex series of steps in a database package? 6. In pairs, decide on two different modern programming languages that you will research. Individually at first, research and write a report comparing these two programming languages, looking at factors such as purpose, key features, interface and impact on environment or society. After completing this report, swap with your neighbour, noting any information your neighbour has found that you can add to your report and give your partner feedback on anything they might have missed that you found out. Be prepared to give feedback to the rest of your class on the languages you both researched. 7. Take the report you produced in question 6 and add some further detail regarding how each language represents standard constructs and the range of data types provided. You should also compare the editing features of the languages and describe how the high-level code is translated and executed. SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 35 SUBJECT CONTENT Designing a program Once a language has been chosen to program in, the programmer should draw up sketches or prototypes of the user interface for the program and a design of the logic of the program. This design of the program logic can either be in text format as a list of instructions outlining how the program will run, called pseudocode, or graphical using diagrams such as structure diagrams. Pseudocode helps a programmer find mistakes in the logic of the program design early, before wasting too much time getting stuck into the actual rules of the programming language being used. Pseudocode maps out each step your program will need to follow in the programmer’s native spoken language, eg English. Programmers start with a very general description of the task involved and then break down (refine) each step into more detail. This is called top-down design. Eventually the pseudocode should describe every possible step required of the computer to complete the task or problem. A simple example of pseudocode is shown below. 1. Get co-ordinates of target. 1.1. Have drone pilot type target co-ordinates. 1.2. Ensure co-ordinates are valid. 1.2.1. Ensure target co-ordinates are in the correct format. 1.2.2. Make sure drone has enough fuel to reach co-ordinates and return. 1.3. Store co-ordinates in memory. 2. Get drone’s current co-ordinates. 3. Plot course so drone reaches target. 4. Take photos of target area. Structure diagrams in basic terms are read from top to bottom and left to right, describing the steps involved in a task from a bird’s eye view. An example of a structure diagram is shown below. 36 SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 SUBJECT CONTENT Exercises 1. Choose one of the tasks below and write pseudocode and draw a structure diagram for it. Getting to school. Going to Spain. Texting a friend. Becoming a pop star. 2. Part of a program design is shown below. 2.1 2.2 2.3 2.4 2.5 Ask for age. Loop while age < 18. Display error message. Ask for age. End loop. Name the design notation that has been used above and explain the purpose of this part of the program. 3. Name and describe a graphical design notation and explain an advantage this notation would have in comparison to pseudocode. SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 37 SUBJECT CONTENT Writing programs To create the initial program or source code, programmers use an editor. The editor is a program that looks like a word processor but has special features to make the process of writing, editing and printing code easier, such as offering to auto-complete commands, colour coding, highlighting of errors and pop-up help windows. Below is an example of the editor in a programming language called Visual Basic 6. Computational constructs This section discusses the building blocks of programs; as mentioned previously there a huge number of programming languages all with different rules and interfaces. The programming languages covered by a school will vary and change from year to year and staff to staff, and it would be very difficult to provide a programming manual in this document for all of them. Staff will have programming notes and resources already for the languages used in a particular school, so this section just takes an overview of the theory behind the building blocks of programs to help learners with general written assessments on programming. Variables Earlier it was mentioned that computers follow an input, process and output model. Once data is input into a program the computer needs to find a place to store the data before it is processed and output as information. To make this data easier to handle in the computer memory it is stored as a variable. Variables are named or labelled storage locations in the computer memory, they are used to store one bit of data at a time but can be reused and at any time what is stored inside a variable can change, hence the name 'variable'. 38 SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 SUBJECT CONTENT Before writing a program the programmer decides whether variables will be needed and then plans how many variables will be required and what the variables will hold (text, numbers, etc). This is called declaring variables. Like homes and mobiles phones, each variable must be able to be uniquely identified and so is given a distinct name. Depending on the programming language used, there will be rules for what can and can’t be used as a variable name. For example, in the language BASIC variable names can’t start with a number, have full stops in the name or be the same as keywords used within the language such as ‘else’ or ‘if’. Variable types In this course the following variables are covered. String String variables are used to hold text, for example names and addresses. Even though an address such as ’22 Acacia Avenue’ might contain numbers, the number part of the string isn’t being used in a calculation. Numbers (integer and real) Numbers can be either whole numbers (integers) or numbers with decimal places (real numbers). Boolean A data type that only holds one of two values: true or false, yes or no. 1D arrays A special category of variable. Normal variables store a single piece of data at a time. Any new data assigned to a variable overwrites the old data. An array is one variable name that can hold multiple pieces of similar data, for example a HighScore (number) stores a number of high scores in one place. SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 39 SUBJECT CONTENT Exercises 1. When writing a program, what is the name given to the software tool used to type in the textual program instructions? State two features of this type of programming tool. 2. Classify each of the following as integer, string or real: (a) 151 (b) Billy Bunter (c) 39.99 (d) DD4 1AB (e) 0.25 (f) –200 (g) MR2 (h) 321 (i) Zebra (j) –9.99 (k) 0.00001 (l) 10 Yemen Street 3. Which one of the following options would be most suitable for storing the postcodes of 20 customers? A B C D 4. A programmer could use a text editor to: A B C D 5. 365 string variables 365 numeric variables An array of strings An array of numbers Which one of the following options would be the most suitable for storing the nine scores in a bowling competition? A B C D 40 translate a program into machine code copy and paste sections of code carry out test runs of a program automatically check a program for logic errors Which one of the following options would be the most suitable for storing the average rainfall for each day of the year? A B C D 6. A string of arrays 20 numeric variables 20 string variables An array of strings Nine string variables Nine numeric variables An array of strings An array of numbers SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 SUBJECT CONTENT 7. A program stores the number of patients in each of six hospital wards in Bobland Royal Infirmary. Which is the best method of holding these six data items? A B C D An array of real numbers An array of integers Six real variables Six integer variables 8. What type of variable would be used to store a list of names? 9. What type of variable would be used to store whether or not an employee had a driving licence? SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 41 SUBJECT CONTENT Programming constructs For programs to be useful, programmers need to use one or more constructs (building blocks) in the code they produce. There are a number of common constructs among programming languages. Assignment Assignment involves placing a value into a variable within a program. A value can be assigned in a number of ways: by fixing a value to it within the program code, by performing a calculation and placing the result into the variable, or by asking the user for input and then placing that user input into the variable. Expressions Expressions can be used in a program to get the computer to perform a calculation using a mathematical operation such as addition, subtraction, division and multiplication. Sequence Sequence simply means making sure a program executes commands in the correct order, for example if a program takes in the test scores for a class and calculates the average score displaying it on screen, the program must first obtain the results before the average can be calculated, and similarly the average must be calculated before the answer can be displayed on screen. Selection Selection involves putting in place the instructions, conditions or paths to enable the computer to make a decision as it executes the program code. Repetition Programmers try to write the smallest programs possible; smaller programs mean less code to type, less code to check for errors and less code for the computer to read through (program runs faster). A key tool a programmer can use to achieve this is the use of loops or repetition. Loops can be either fixed or conditional. Fixed loops mean that the programmer decides at the time of writing the code how many times the code should be repeated, eg displaying a message on screen five times. Conditional loops are for when the programmer does not know how many times the code should be repeated, eg asking for the user to enter a correct password. 42 SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 SUBJECT CONTENT Pre-defined functions Depending on the programming language being used, the makers of the programming environment often include some ready-made commands or tools which perform quite complex tasks without the programmer having to create the code from scratch themselves. The pre-defined function takes in a single value and delivers a single value. An example of this would be the INT function in Visual Basic, which turns a real number into a whole number by lopping off any decimal places. For example: INT (grade_average) = formatted_ grade_average This line of code takes a grade average, for example 16.798, takes off the .798 and stores the integer 16 into a new variable called formatted_ grade_average. Pre-defined functions save time when writing the code and testing the code as they have already been tested by the makers of the programming tool being used. Algorithms An algorithm is simply a set of instructions or steps that the computer follows to achieve a task or solve a problem. Some problems or tasks are common to most programs, such as the ability of a program to search for an item, to count how many times something happens or to find the highest or lowest value in a list. Programmers will have a set way of solving these tasks or standard algorithms. At this level of study learners are expecting to know about an algorithm called input validation. They also need to know about FindMin, FindMax, Linear Search and Count Occurrence. Input validation Input validation is a piece of code that ensures that what the user inputs into the program is in a suitable format for the program to handle properly. An example of this might be if a program is taking in a test score and the test is out of 100, then the programmer will want to ensure that the user doesn’t put in a test score of 120, or twenty or –15. Input validation algorithms use a loop (repetition) to take in a value from the user, check whether it is within a sensible range and, if not, give the user a meaningful message to try again; it keeps on looping until the user inputs the data in the correct format. This type of loop will be a conditional loop as the programmer does not know in advance how long it might take the user to get the format or range correct. SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 43 SUBJECT CONTENT An example of this algorithm using pseudocode is shown below: 1. 2. 3. 4. 5. 6. Ask for user to input value. Store the input value. Loop while input value in not within acceptable range. Ask user to re-enter the value in correct range. Store the input value. End loop. An example of this in Visual Basic might be as follows: Test_score = InputBox(“Please enter a test score out of 100”) While (Test_score < 0) OR (Test_score > 100) Test_score = InputBox(“ERROR….Please re-enter a score between 0 and 100”) Wend Exercises 1. A section of program code is shown below. What type of statement is it? let minimum_age be 21 A B C D Conditional loop Fixed loop Conditional statement Assignment 2. A program is required to calculate how many days there are for a given number of weeks. Use pseudocode or a programming language of your choice to show how this could be implemented. 3. Below is an algorithm to work out the speed of a missile. Look at the sequence of steps and explain where there is a problem. Rewrite the steps to produce correct results. 1. 2. 3. 4. 44 Take in distance travelled by missile. Display the speed of the missile. Take in the time taken to travel this distance. Calculate the speed of the missile. SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 SUBJECT CONTENT 4. A computing professor has asked his students to design and write a program to satisfy the following specification. Create a program to take in the marks of 20 students in a recent class test out of 100. It should calculate and display the average mark to the nearest whole number. One student produces the design below. 1 2 3 4 5 6 Set total to 0. Loop 20 times. Get valid mark. Add mark to total. End loop. Calculate and display average mark. What type of loop has the student chosen in her design? 5. The example in the question above requires further refinement to ensure that only a valid mark is accepted. Using the same design notation, write the refinement for step 3 or alternatively write the code in a language with which you are familiar. Assume that the user is to be prompted to enter the mark. 6. A section of code in a program is to be repeated until a particular item of data is entered by the user. Which type of loop is required to implement this? A B C D Fixed loop Conditional loop Nested loop Infinite loop SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 45 SUBJECT CONTENT Errors in programs When a programmer is inputting code and running it to see if it works, the code won’t always work. This may be because of errors in the code the programmer has typed, called bugs. The types of errors programmers make come into three categories: 1. Syntax errors These are errors made when a programmer types instructions into the editor, for example misspelling a reserved word (INTERGER instead of INTEGER in Visual Basic) or variable name (variable is declared as HIGH_SCORE, but later on it is mistyped as THIGH_SORE). 2. Run-time errors Run-time errors don’t come to light until the program is executed or run. A run-time error happens when a program gets data but doesn’t know what to do with it. A very simple example of this might be if a program asks for the user to enter a test score which the program will then proceed to assign a grade to, such as an A, B, C etc, dependent on what percentage the learner gets in the test. In this example, if the user puts in text as the test score, eg seventy instead of 70, the programming code may then falter because it was expecting a number and not a string and therefore can’t execute the rest of the code properly. 3. Logic errors Logic errors occur when the program has the wrong commands or the commands are not in the correct order or sequence. Essentially the commands the programmer gives are not clear or specific enough and therefore the computer gives unexpected results. An example of this in real life might be if staff asked learners to complete a homework task. If staff do not give very specific instructions the homework might not come back in time, might not be the learner’s own work or might not be of the requisite quality. Logic errors can be hard to spot because the program might run but the end result might be incorrect and without thorough testing it may go unnoticed. An example of this might be a satellite navigation program that when Perth in Scotland is typed in as a location, directs the user to Perth in Australia. The program gives a result but the result in incorrect. 46 SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 SUBJECT CONTENT Testing Testing is the process of checking that the program works as planned. When testing a program, the programmer should run the program a number of times with different kinds of user input to see how the program responds and whether the output from the program is as expected. When picking data to test the program with, a programmer should be methodical and pick data that will test the program as thoroughly as possible. Test data should cover the following categories: Normal – the programmer tests the program with the average sort of data the program would be expected to deal with. Extreme – the programmer tests the program with data right on the limit or boundary of what the program would be expected to deal with. Exceptional – the programmer tests the program with data outside of what the program has been designed to process. How does the program handle a user typing in ‘fifteen’ instead of 15 when asked for their age? Example test data A program is designed to take in learner test scores, add them together and produce a class average. The test is out of 30. Below is an example of the test data that could be used to check that the program works. Normal test data: 10, 15, 20. Extreme test data: 0 and 30. Exceptional test data: –1,100, fifteen. Maintenance After a working program has been produced, a programmer’s work isn’t done, Sometimes it is necessary to go back to a program: to fix a problem spotted later by users (perfective maintenance) to update the program to work with a new piece of hardware or software (adaptive maintenance) to add new features to the software (perfective maintenance). Programmers can make the job of going back and changing software easier by making their programs more readable. Improving the readability of a program can be achieved using the following techniques: Add lines of comments into the code to document when the program was written and by whom, what the purpose of the program is and explaining what certain parts of the program do. These little ‘sticky notes' in SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 47 SUBJECT CONTENT the program are ignored by the computer but can really help a programmer looking back at a program written some time ago or at code that has been written by someone else. Their proper name is internal commentary. Variables should be given meaningful names, for example if a variable stores a high score for a game, it could be called something that gives the reader a clue as to what it holds such as ‘high_score’ rather than something meaningless like ‘variable1’ or ‘x’ or ‘spam_fritter’. When writing a story or essay it is important to punctuate the text with full stops, commas and paragraphs. These help the reader scan the text and take in the information in manageable chunks. Similarly, programmers should punctuate their code with white space and indentation (like tabulation in word processing), making the code easier to understand when it comes to fixing errors or making changes. Internal comment White space Meaningful variable name Meaningful Screenshot of a maintainable program in Visual Basic variable name Indentation 48 SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 SUBJECT CONTENT Exercises 1. A program has been written to process scores out of 20 in a recent science test. Choose the most suitable set of test data below to fully test this code. A B C D 12, 3, 16, 9, 10, 15 -1, 20, 0, 21, 15, 2 0, 4, 16, 10, 19, 20 1, 2, 3, 4, 5, 6 2. A program is being written to take in the age of customers to allow a company to target them with suitable advertising and promotions. A program like this should be tested with several sets of test data to make sure that the age-inputting part of the program is working. List and label any six data items that would thoroughly test that this part of the design works properly. 3. Swap your test data from question 2 with your neighbour and evaluate their test data. Did they miss anything out? Did they include a type of test data that you didn’t? Give your neighbour some verbal feedback after looking at their work and together come up with an agreed set of six items of labelled test data. Be ready to give an example to the rest of the class. 4. Name and describe two kinds of programming error that can be made. 5. Name and describe three steps a programmer can take to make code more readable. 6. Why is it important that a programmer makes their code readable? 7. In pairs, debate which is more important in making code more readable: meaningful variable names or internal commentary. Each person should take one of these measures and spend 1 minute putting a case forward to the other partner. When both people have made their argument, try to agree on which is the most important. If you cannot, why not? Be ready to justify your findings to the rest of the class. SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 49 SUBJECT CONTENT Glossary Below is a glossary of common computing terms that you may come across during your studies. Algorithms Analysis Application software Applications package Arithmetic/logic unit(ALU) Array ASCII Back up Backing storage Backing storage medium Binary Binary language Biometrics Bit Byte Central processing unit (CPU) Coding the program Compiler Computer system Conditional loop 50 Set of instructions used or sequence of steps taken to solve a problem. The analysis stage involves reading and understanding a problem. Comprises all the programs you apply to a task, such as writing a report or sending an email. Software that performs a particular task such as word processing or desktop publishing. Component of the processor of a computer that does the calculations and makes the decisions. Set of data items of the same type grouped together using a single identifier. A 7-bit code allowing 128 different characters to be represented. A second copy of a program or file made in case the original is lost or damaged. Permanently holds data on media such as disk or memory card. The physical item which holds data such as USB pen drive. Counting using two digits, 1 and 0. Machine language represented using a series of 0s and 1s. Security method using physical characteristics to identify a user such as fingerprints, retinal scan or voiceprint. A binary digit, either one (1) or zero (0). A collection of eight bits. The hardware component that processes data. Writing programming language instructions. Translates a high-level language into machine code in one go. A combination of all the components required to process and store data using a computer. A condition must be met for the loop to be carried out. SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 SUBJECT CONTENT Conditional statement Control unit Debugging Documentation Embedded system Encryption Evaluation Exceptional test data Extreme test data Field File management File server Fixed loop Flowchart Graphical user interface (GUI) Hardware High-level programming language HTML Human computer interface (HCI) Icons Implementation Simple decisions, for example IF condition is true THEN carry out instructions. Controls parts of the processor and ensures instructions are in the correct order. The process of finding and correcting program errors. All the supporting paperwork for a program. Minicomputer inside another piece of equipment such as a car or a mobile phone. Formatting a message into a secret code so that it can’t be understood by anyone who is not authorised to view it. Evaluation involves reviewing a solution against a checklist of requirements, highlighting any strengths, weaknesses and improvements needed. Test data that should be rejected by the program. Test data that is on the limit of acceptability. A single item of data stored in a record. A function of an operating system dealing with how files are held, controlling the process of saving or loading files from disk. Central disk storage for user's programs on network. A loop that is carried out a set number of times A pictorial representation of the logical steps it takes to solve a problem. Allows users to interact with a program in a graphical environment. The equipment or physical devices that are associated with a computer. Supports English-like syntax. Hypertext mark-up language – the language used to write web pages. The means by which a computer and user communicate. Symbols or pictures on a screen. Changing a program design into instructions that the computer can understand. SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 51 SUBJECT CONTENT Import Information Input Input device Integer Interface Internal commentary Interpreter Logic error Loop Low-level machine language Machine code Macro Mailbox Maintenance Meaningful variable names Menu Non-volatile 52 To bring in data from one program file to another. Data that has been processed. Describes the entry of data items into computer memory using hardware devices such as a keyboard or mouse. Allows data to be entered, such as a scanner or a mouse. A whole number without a decimal point. Part of a computer system that allows different devices to communicate with the processor by compensating for any differences in their operation. Text inside a program that explains what a program does. Changes a high-level language into machine code one line of code at a time, every time the program is executed. An error in a program that does not necessarily stop the program from working but can produce an unexpected or incorrect result. Instructions might be performed in the wrong order, too many times or not at all. To repeat a set of instructions a number of times, either fixed or conditional. Made up of 1s and 0s that the computer understands. Also called machine language. Computer language made up of binary numbers (0 and 1 only). A set of commands activated by a single keystroke. Where electronic mail is stored while waiting to be read/downloaded. Consists of all the improvements and corrections made to a program after it is in production. Names given to variables, functions, procedures, etc. Should have meaning and indicate the purpose of the item named. List on screen from which choices may be made by the user. Describes storage whose contents are retained when power is lost. SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 SUBJECT CONTENT Object code Object-oriented programming Online help Online tutorial Operating system Optical character recognition (OCR) Optical storage Output Password Pixel Portability Processing data items Processor Program Programming Programming language Pseudocode Random access Translated machine language. A programming model that focuses on objects or ‘things’, and describes their features (or attributes) and their behaviours. Help available in the form of information screens built into the program being used. Step-by-step lessons on how to use a computer program. Programs that control the operation of a computer system. Characters on paper can be digitised into an editable document for use on the computer. A form of non-magnetic storage read by a laser beam being reflected off the pits and bumps on the disk surface. Describes the operation of retrieving information from memory and sending it to a device, such as a monitor or printer, so people can view, interpret and use the results. A secret code used to gain access to private information on a computer system or to log on to a network. Short for picture element; small dots used to make up a picture on a screen. Term used to describe whether a program can work on a number of different computer systems. May involve organising items, checking them for accuracy or performing calculations with them. The part of a computer that carries out the process. A list of instructions that tell the computer what to do The act of developing and writing programs. Includes languages such as Visual Basic, C#, C++ and Java. Used to write programs. Design notation using a numbered list of steps using English-like phrases representing the logical steps it takes to solve a problem. Files are accessed directly. SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 53 SUBJECT CONTENT Random access memory (RAM) Read-only memory (ROM) Readability Record Registers Rich text format Scripting languages Scrolling Selection Sequential access Software Spreadsheet Standard file formats Structure diagram Structured listing Technical guide Template Text editor 54 Computer chip that stores data temporarily; data are lost when the computer is powered down. Computer chip that stores data permanently: data are not lost when the computer Is powered down. How easy it is for another programmer to understand and adapt a program. Data structure consisting of multiple fields of information. Fast-access memory locations inside a processor. Stores information about text, including formatting. Examples are Python, Perl and PHP. Used to write programs that are typed directly from a keyboard and stored as text rather than as binary executable files. Moving the display on the screen using cursor keys or a mouse. Involves making a decision using a construct such as an IF...statement. Files are accessed one after another. The computer instructions that tell the hardware what to do. A program used for numeric data, calculations and graphs divided into rows and columns. The individual cells in a spreadsheet can contain text, numbers and formulae. A way of storing data for use by a number of different application packages. Represents the logical structure of a program design using a tree of linked boxes. A print-out or screen display of the lines of code in a computer program. Contains the installation instructions and technical requirements of a piece of software. Ready-made structure/layout for a document. Allows source program code to be entered and changed. SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 SUBJECT CONTENT Translator User guide Username Validation Viruses Converts a high-level language program into low level machine code so the processor can use it. Explains the functions and features of a piece of software. The means of identifying a user on a computer system or network. A check carried out by the computer on any data to see if it is unreasonable or incomplete, for example to see if a value is within a range (range check). Harmful piece of software that attaches itself to a file, reproduces and spreads. Qualifications The requirements for a qualification in Computing Science at National 4 and 5 are laid out in the SQA documentation, which can be accessed from http://www.sqa.org.uk/sqa/48477.html. To gain a course award, a learner must pass all units as well as the Added Value Unit at National 4 or the course assessment at National 5. The course assessment will contain the Added Value Unit and will consist of a question paper and an assignment. The assignment will be assessed under controlled conditions and marked externally. SOFTWARE DESIGN AND DEVELOPMENT UNITS (COMPUTING SCIENCE NAT 4/5) © Crown copyright 2013 55