Computation is a fundamental part of our world, with today's children growing up surrounded by technology. This has led governments and policymakers to introduce computer science into primary and secondary education (age 5 to 16). These developments have been driven by 'computational thinking': the idea that the problemsolving skills used in computer science are useful in other disciplines. They have resulted in a wide range of programming tools designed for novices, of which Scratch, a block-based visual programming environment, is the most popular. Yet, so far, both computer science education and claims of computational thinking as a universal skill have failed to live up to their potential. This thesis begins by reviewing the literature on computer science in primary education and computational thinking. It then describes a study that aimed to reproduce findings that programming improves story sequencing, a non-computational skill, in young children (age 5 and 6) using a programming game. The results showed an overall improvement for both the intervention and control group. In addition, it highlighted issues with teaching programming to young children. The thesis then refocuses on teaching older children (age 9 to 11) the computer science skill of abstraction and the idea that it can be used to refactor code to remove 'code smells' (bad programming practices). Code smells indicate an underlying problem in a program, such as code duplication, and are common in Scratch projects. A study is then reported that establishes that primary school children can recognise the benefits of abstraction when asked to alter Scratch projects that contain it. The thesis then describes the design and development of Pirate Plunder, a novel educational block-based programming game designed to teach children to use abstraction in Scratch, using custom blocks (parameterised procedures) and cloning (instances of sprites). Two studies are reported in the subsequent chapters. The first investigates the value of a debugging-first approach in Pirate Plunder, finding that it was not always beneficial. The second measures for improvements in using abstraction in Scratch, finding that children who played the game were then able to use custom blocks to reduce duplication code smells in a Scratch project. In addition, Pirate Plunder players improved on a computational thinking assessment compared to the non-programming control group. The final chapter discusses the original contributions of the thesis, the implications of these and future direction. Declaration I hereby declare that: 1. I have not been enrolled for another award of the University, or other academic or professional organisation, whilst undertaking my research degree. 2. None of the material contained in the thesis has been used in any other submission for an academic award. 3. I am aware of and understand the University's policy on plagiarism and certify that this thesis is my own work. The use of all published or other sources of material consulted have been properly and fully...