Introduction to ProgrammingUnit 1: ProgrammingUnit code: D/615/1618Unit level: 4Unit Credit value: 15 (Total of about 150 study hours)Learning outcomesBy the end of this unit students will be able to:LO1. Define basic algorithms to carry out an operation and outline theprocess of programming an application.LO2. Explain the characteristics of procedural, object- orientated andevent-driven programming, conduct an … Continue reading “Introduction to Programming”
Introduction to ProgrammingUnit 1: ProgrammingUnit code: D/615/1618Unit level: 4Unit Credit value: 15 (Total of about 150 study hours)Learning outcomesBy the end of this unit students will be able to:LO1. Define basic algorithms to carry out an operation and outline theprocess of programming an application.LO2. Explain the characteristics of procedural, object- orientated andevent-driven programming, conduct an analysis of a suitable IntegratedDevelopment Environment (IDE).LO3. Implement basic algorithms in code using an IDE.LO4. Determine the debugging process and explain the importanceof a coding standard.2What is programming?■ Computer programming is the act of writing algorithms (a setof instructions) that tell a computer what to do.■ These algorithms are executed by a computing device (PC,Laptop, mobile device, tablet, washing machine, car alarmsetc.)■ People who program are referred to as programmers.■ Computer programmers write, test, and maintain the detailedinstructions, called programs, that computers must follow toperform their functions.■ Programmers also conceive, design, and test logicalstructures for solving problems by computer.3Why learn programming?■ It is not so difficult – technical common sense■ Can be a rewarding profession – software developersare well paid■ Can be fun and less stressful■ Computers and software systems have penetrated ourlives in many ways – it is good to know programming,even if you are in other fields.4How hard is learning how to program?■ May seem difficult for beginners:– Analogous to learning how to ride a bicycle – practice makes thelearning enjoyable and fruitful■ Initial frustrations:– Making frequent syntax (language rules) errors– Struggling for hours to fix errors– Logical (design related) errors■ As experience grows– Syntax errors go away– Logical errors can still happen– Keeping up with technology and the need to learn continuouslycan be a pain5 Useful tips to rememberwhile learning programming 61. Take time to learn■ Everyone has a different style and pace of learning■ Don’t rush – you will never become a programmer in fewweeks■ Pick a language that is beginner friendly e.g. Python, Scratchetc.■ If the learning curve is painful, you are trying to learn it tooquickly72. Get your hands dirty■ You will never become a programmer by just readingprogramming books or watching videos passively■ Type in and run the programs yourself – you will learn fasterfrom your own mistakes■ The act of typing is a practice in itself to get the languagesyntax right83. Utilize examples■ Don’t feel you have to create everything from scratch, Learnfrom other peoples work■ If you learn better by looking at examples than reading books,there are plenty of examples online94. Don’t be a keyboard designer■ Understand the problem first before you start coding■ Plan before you code■ It is easier to focus on implementation whenfunctionality is clearly understand■ Make a practice of writing high level pseudo code before coding– unfortunately, this is not insisted up on in most programmingcourses and not followed in practice105.Find a meaningful project■ Create an app that solves an existing problem■ May be someone you know has a programming problem■ It will increase your confidence level116. Use a good IDE■ Good Integrated Development Environments (IDEs) take careof mundane things and make programming experienceenjoyable■ Examples: MS Visual Studio, NetBeans, Eclipse, PyCham,InletiJ IDEA127. Learn in a group■ Learning in a group setting or with a friend■ Discuss ideas and help each other when you get stuck.■ Enables you to work on a team assignment■ Self-paced learning alone is not for every one■ It requires lot of self-discipline & it is not much fun138. Don’t be too stubborn■ Get into the habit of fixing errors as soon as they occur■ BUT don’t spend too long bogged down on one issue■ Discuss it with someone else, get help from the community(e.g. Stackoverflow)■ Sometimes its better to leave a stubborn issue and move onto other tasks and comeback to the issue later■ If not, your frustration level will increase & confidence will godown.149. Participate in the community■ Join communities e.g. Stackoverflow and help others■ After a while, you will be surprised how much you know■ Most programming issues you will face, will have beenencountered by someone else before you1510. Use video tutorials■ Here are some free ones■ www.khanacademy.org/cs■ https://www.youtube.com■ https://mva.microsoft.com/■ https://channel9.msdn.com/■ etc.■ There are also many you can subscribe to (Not FREE)16Software Categories■ Application Software:Programswritten for computer users– Word Processors,Spreadsheets– Database s/w– Drawing programs– Web browsers, emailprograms– IDEs■ System Software: Programswritten for computersystems– Operating Systems:Windows, MacintoshOS, Unix/Linux– Device drivers– Compilers, Interpreters,PreprocessorsSoftware is comprised of instructions that get a computer to perform a task.17Operating System (OS)• Provides several essential services:– Loading & running application programs– Allocating memory & processor time– Providing input & output facilities– Managing files of information18Programming Languages■ Programming languages allow programmers to code software.■ The three major families of languages are:• Machine languages: Uses binary code,dependent, Not portable– Assembly languages: Uses mnemonics,MachineMachinedependent, Not usually portable– High-Levellanguages:UsesEnglish-likelanguage,Machine independent, Portable (but must be compiled for differentplatforms)■Examples: Python, C, C++, Java, C#, F#, PHP, JavaScript, Fortran, . . . 19Machine Languages■ Comprised of 1s and 0s■ The “native” language of a computer■ Difficult to program – one misplaced 1 or 0 will cause theprogram to fail.■ Example of code:1110100010101101110101101001110101011101010001111011120Assembly Language■ Assembly languages are a step towards easier programming■ Asymbolic representation of the machine language of a specific processor.■ Is converted to machine code by an assembler.■ Usually, each line of assembly code produces one machine instruction (One-to-onecorrespondence).■ Programming in assembly language is slow and error-prone but is more efficient interms of hardware performance. ■Mnemonic representation of the instructions and dataExample:Load PriceAddTax Store Cost21High-level language■ Much easier to program than in assembly language.■ The syntax of HL languages is similar to English using Englishkeywords such as “FOR”, “WHILE” or “IF“, … etc.■ Each statement corresponds to several machine languageinstructions (one-to-many correspondence).■ Data are referenced using descriptive names■ Operations can be described using familiar symbols■ Example:Cost = MarkedPrice * VatRate22Procedural & OOP■ Historically, we divide HL languages into two groups:– Procedural languages– Object-Oriented languages (OOP)23Procedural Languages■ Early high-level languages are typically called procedural languages.■ Procedural languages are characterized by sequential sets of linearcommands. The focus of such languages is on structure.■ Examples include C, COBOL, Fortran, HTML24Object-Oriented Languages■ Most object-oriented languages are high-level languages.■ The focus of OOP languages is not on structure, but on modeling data.■ Programmers code using “blueprints” of data models called classes.■ Examples of OOP languages include C++, C#, Virtual Basic, Java and Python25Compilers & Programs■ Source program– The form in which a computer program, written in some formalprogramming language, is written by the programmer.– Can be compiled automatically into object code or machine code orexecuted by an interpreter.– Python source programs have extension ‘.py’26Compiling■ Regardless of the HL Language, all HL programs needto be translated tomachine code so that a computer can process the program.■ Some programs are translated using a compiler,othersusing an interpreter■ When programs are compiled, they are translated all at once.■ Compiled programs typically execute more quickly than interpretedprograms, but have a slower translation speed.27Compilation■ Compiler translates source into target (a machine language program)■ Compiler goes away at execution time■ Compiler is itself a machine language program, presumably created by compilingsome other high-level program■ Machine language, when written in a format understood by the OS is object codeCompilerTarget ProgramSourceProgramTargetProgramInput Output28Interpreting■ Some programs are translated using an interpreter.■ Such programs are translated line-by-line instead of all at once (like compiledprograms).■ Interpreted programs generally translate quicker than compiled programs, buthave a slower execution speed.29InterpretationInterpreterSourceProgramOutputInput• The interpreter stays around during execution• It reads and executes statements one at a time30Mixture of C & ITranslatorSourceProgramIntermediateProgramIntermediateProgramVM OutputInput• Many programming languages implementthis• Interpreter implements a Virtual Machine (VM).31NEXT TOPIC…ALGORITHMS ANDPSEUDOCODE32Independent Study33BooksJason Cannon (2014) Python Programming for Beginners: An Introduction to the Python ComputerLanguage and Computer ProgrammingJohn P. Newton (2017) Python Programming: An Easy and Comprehensive Guide to Learn PythonProgramming LanguageJason R. Briggs (2012) Python for Kids: A Playful Introduction to Programming 22 DecJournalsThe Institute of Engineering and Technology (IET)British Computer Society (BCS)WebsitesHN Global | BTEC Higher Nationals at https://www.highernationals.com/hn-globalAcademic Writing BooksBailey, S. (2011), Academic Writing – A Handbook for International Students, London, RoutledgeBurns, T. and Sinfield, S (2016), Essential Study Skills: The Complete Guide to Success at University,Los Angeles, SAGE,Swales, J. M and Feak, C, B. (2012), Academic Writing for Graduate Students, Ann Abor, The Universityof MichiganReflection,Questions&FeedbackIntroduction to ProgrammingUnit 1: Programming