Presentation is loading. Please wait.

Presentation is loading. Please wait.

Software Development – Topic 2 Types of Programming Language.

Similar presentations


Presentation on theme: "Software Development – Topic 2 Types of Programming Language."— Presentation transcript:

1 Software Development – Topic 2 Types of Programming Language

2 This unit covers Different types of programming languages Different types of translators Module Libraries

3 Types of Language Programming languages can be classified as Procedural Declarative Event driven Scripting

4 Procedural Language Step by step method for solving a problem Code is laid out in a sequence Design for a procedural language is called an algorithm Clear start and end points Good design will have a one to one mapping of code to algorithm

5 Examples of Procedural Language ALGOL Pascal True Basic C

6 Declarative Languages Different approach to solving the problem 1. Write down all the known facts 2. Write down all known rules 3. Perform queries to solve the problem Facts and rules are used to satisfy the query and solve the problem Good at solving logical problems and used in Artificial Intelligence

7 Examples of Declarative Languages PROLOG LISP A declarative language would be used to write these guessing games guess the animal game guess the tv or movie Finds the answer by pattern matching the question with the stored rules

8 Event Driven No specific start and end to the program Screen design with graphics, buttons, etc Code attached to object Code is similar to a procedural language but is activated in any order ie by clicking on the correct button

9 Visual basic is an example of an event driven language

10 Scripting Languages A scripting language is often provided with an applications package Using a scripting language can help to automate a series of complex actions within a package Scripting is not used for writing applications from scratch Eg – in a database like Access scripting could be used to automate the process of creating a complicated report

11 Macros A way to automate a task that you perform repeatedly in a package You can record each command, store and replay them with ease The macro can be played back to perform the task Tasks performed by macros are usually repetitive The sequence on instructions can be stored and executed by a single instruction

12 Benefits of Macros Complex commands can be reduced to one key press Macros can be set up for new users to help them with complicated tasks The range of the application package can be extended through the use of macros

13 Glossary Definitions Write a glossary definition for each of the following at the back of your jotter Declarative Language Procedural Language Event Driven Language Scripting Language Macro

14 Written Task Answer questions 12 – 15 on page 52 of How to Pass Higher Computing

15 Practical Task Use the macro feature in Microsoft Word to record a macro to automatically enter the name and address of a company on a blank word document Include a piece of clipart in the letterhead

16 Complete the following past Paper questions in your jotter 1. What is the main difference between procedural and event driven languages? 2 marks 2. Programming languages can be classed as procedural, declarative or event driven. Name the most common type of program that is written using a declarative programming language. 1 mark

17 Suggested Answers 1. A procedural language sets out commands in a linear way with a definite start and stop position to the program code whereas an event driven language reacts to events such as key press and mouse clicks to activate the attached code in any order 2 marks 2. artificial intelligence or expert systems 1 mark

18 Extended Response Past paper question which test what you have learned so far Open your past paper book at 2003 paper Q 18 Take time to study the interfaces and then think about how you would attempt to answer part a)

19 What you should be thinking 1. First of all think of your definition of robust Robust – can cope with errors while running and will not fail when unexpected input is entered or unexpected results are generated 1. Is interface A robust? – could invalid data be entered 2. Is interface B robust – if so why?

20 Use the same method to answer the rest of part a) Efficient - does not use unnecessary memory or processor time Which program is most efficient and why?

21 Break down your answer – to get 3 marks you must have commented on each criteria for each interface – to summarise RobustEase of Data Entry Efficiency Interface A Prone to errors as name could be mistyped Requires keyboard skills Not memory or processor intensive Interface BInvalid entries not possible as user selects from a list therefore more likely to be robust Could be used easily by inexperienced users as options are given Uses more memory/ processor power to draw menus

22 Past Paper 2003 – Q 18 cont’d You should also be able to answer part b) make sure you write enough to gain full marks

23 Suggested answers b) An event driven language uses a GUI which make it easy to create drop down menus or combo boxes Code can be easily linked to objects A procedural language would make it difficult to implement Interface B as a vast amount of code would be needed to generate the menus

24 Summary of What you need to know about types of programming languages Description and comparison of Procedural, declarative and event driven Description of the features and uses of scripting language (including macros) Explanation of the need and benefits of scripting languages NOTE – You must be able to use your knowledge above an apply it to a variety of problem solving scenarios

25 More practice on comparison of programming languages The following question was taken from a past prelim paper Using the technique for the previous question attempt to answer as comprehensively as possible The first part is worth 3 marks The second part is worth 2 marks Draw a table if it helps you

26 1.Describe each of these interfaces in terms of ease of data entry and robustness 2.Describe two features of an event driven language which would make it easier to implement Interface C compared to using a procedural language.

27 Suggested answer – part 1. Interface A: Ease of data entry – requires keyboard skills, required data value must be know by user Robustness: Invalid / inaccurate entries can be entered. Interface B: Ease of data entry: B can be used with little IT experience, values available on menu. Robustness: Valid options are shown Interface C: ease of data entry: Keyboard skills with auto complete or select from menu robustness: Valid options are shown – no invalid data 1 mark for 2 correct points against each interface

28 Suggested answer – part 2 Standard routines can be used for the creation of buttons linking of buttons to segments of code Easier to create a graphical user interface than with a procedural language List boxes, combo boxes or drop downs are easily created/available in an event driven language

29 More Past Paper Questions Use the past paper book and look at the 2000 paper – Section 2, Q2 Think about the GPPs you know of. Which one would be most suitable for creating a student tracking system? Now try to answer parts a) and b)

30 Suggested Solution – part a) Easier and faster to implement the program using a GPP as coding already exists to enter and edit data Could be implemented with creation of a database which would mean only data files and user interface would need to be created Tracking System would be created using tried and tested software which is error free

31 Suggested solution – part b) (i) A macro is a sequence of instructions which have been stored and can be executed but issuing a single instruction (ii) Macro could be used to Select data and print reports Create and update user details 3 marks

32 Checkup You should now complete the check up on Types of programming languages Types of programming languages

33 Different programming Languages use Different Translators

34 Translators All high level programming languages must be translated into machine code There are two types of translator Compilers Interpreters

35 Compiler Takes the entire program file (source code) and translates it in a single operation to object code The object code is saved as a new file - this is an executable file

36 Advantage of Compilers When source code has been translated once it does not need to be translated again This means The program runs faster The translator doesn’t have to be loaded into memory for the program to run

37 Disadvantage of Compilers Code will not run if there are any syntax errors

38 Interpreter Takes the whole program file (source code) and translates it one line at a time

39 Advantage of Interpreters Will run all or part of the code even if syntax errors are present

40 Disadvantages of Interpreter No object code is produced This means Translator must be present in memory every time the code is run Code is translated every time the program is run Program is slow to run

41 Thinking time Which type of translator do you think is more efficient and why? Remember what the definition of efficient is: Does not use more memory or processing time than is necessary

42 (Specimen Question paper – Section 2 – Q17 A new payroll system is being written by a software design company During the production of the payroll system the software developers use both an interpreter and a compiler. Describe when each of these translator programs are used and give a reason for its use. 4 marks

43 Suggested solution Interpreter - Used during the writing of the software (1 mark) May give better identification of location of error Ability to test code despite presence of errors in code (1 mark for one valid reason) Compiler - Used after the software has been completed (1 mark) Produces object code for specific chipset therefore no need for subsequent translations Object code runs without translator being present (1 mark for one valid reason)

44 2005 Section 2, Q 23 - Programmers use a compiler and interpreter when constructing code. 1. Why would an interpreter be used when developing software? 2 marks 2. Explain in terms of efficiency the difference between using a compiler compared with an interpreter when translating code related to the following pseudocode 1. Loop 300 times 2. ask user for name 3. store name in array 4. End loop Your answer should include both processor time and memory usage for each type of translator. 2 marks

45 Suggested solution As an interpreter translates the program code line by line coding errors can be pinpointed and dealt with quickly It is possible to run partial code (or code with errors in it) Easiest way to make sure you answer this type of question fully is to put what you know into a table. TranslatorMemory usageProcessor usage Interpreter – each line within the loop would need to be translated every time it is executed (300 translations - inefficient) Interpreter would need to be resident in memory (RAM) during translation which would be inefficient in terms of memory usage Instructions within the loop would need to be translated every time in the loop which would be inefficient in terms of processor time Compiler - translates all of the code before execution - the lines within the loop would only be translated once then executed 300 times – (1 translation – more efficient) Compiler – no need to load the translator into memory each time the program is run making it efficient in terms of memory usage Instructions within the loop would be translated once and run 300 times making it efficient in terms of processor time

46 Module Libraries A module is a section of a program A module library contains pre-written and pre-tested sections of code  Modules can be saved on backing storage to be used repeatedly

47 Advantages of module libraries No need to write the code Code has already been tested Modules should be documented

48 Glossary definition Module Library

49 Why use a module library? Saves time and money during Design Implementation Documentation Testing Care must be taken when using modules to ensure the correct module is used, it is error free and it fits in with the rest of your program (ie use of variables)

50 Past paper questions on module libraries 1. A software company has decided to make use of module libraries. Give two benefits to the software company of using module libraries. Faster implementation by using pre-written code Code is pre-tested Shorter design time Code is already documented (1 mark each for two valid benefits)

51 Learning Outcomes – Software development languages and environments – What you should have learned in this topic Description and comparison of procedural, declarative and event-driven languages Comparison of the functions, uses and efficiency of compilers and interpreters Description of the features and uses of scripting language (including creating and editing a macro) Explanation of the need for and benefits of scripting languages Description of the use of module libraries

52 Check up You should not complete the check up on Type of Languages and Translators Type of Languages and Translators

53 End of topic activities Complete questions 12 – 16 on page 52 Complete end of topic evaluation sheet Complete ActiVote assessmentActiVote assessment


Download ppt "Software Development – Topic 2 Types of Programming Language."

Similar presentations


Ads by Google