Presentation is loading. Please wait.

Presentation is loading. Please wait.

Software Design and Development Languages and Environments Computing Science.

Similar presentations


Presentation on theme: "Software Design and Development Languages and Environments Computing Science."— Presentation transcript:

1 Software Design and Development Languages and Environments Computing Science

2 Learning objectives Learning Objectives By the end of this topic you will be able to: ; understand the difference between high level and low level programming languages understand the difference between high level and low level programming languages know that all programming languages can be reduced to three basic control structures: sequence, selection and iteration; know that all programming languages can be reduced to three basic control structures: sequence, selection and iteration; appreciate that programming languages can be classified in a number of different ways; appreciate that programming languages can be classified in a number of different ways;

3 Learning objectives Learning Objectives By the end of this topic you will be able to: ; explain the differences between procedural, declarative, object- oriented and domain-specific languages; explain the differences between procedural, declarative, object- oriented and domain-specific languages; understand the difference between two types of translation software: compilers and interpreters; understand the difference between two types of translation software: compilers and interpreters; describe the tools a programmer would expect to be available in a modern programming environment. describe the tools a programmer would expect to be available in a modern programming environment.

4 High level and low level programming languages Low-Level languages are the languages which the computer understands directly such as machine code. They consist of binary codes. High-Level languages have to be translated into machine code before they can be understood by the computer

5 Control Structures: Sequence, selection and repetition Sequence: commands will be executed one after the other. Selection: execution depends on whether a condition is true or not. Iteration: a set of commands is repeated for a set number of times, often called a loop.

6 Programming Classification There are a large number of programming languages (more than 2000). One way to classify them is by how they are used Procedural Declarative Object Oriented Domain specific

7 Procedural languages Commonest type of language Programs are a sequence of commands executed in a predictable order. Earliest languages used line numbers Provide standard operations like: + - * / AND NOT OR

8 Procedural Languages Use Control structures like: For.. Next IF.. Then While.. Do Provide Data structures like: Real Integer String Array

9 Procedural Language Examples – Basic – Pascal – C – Cobol – Fortran

10 Declarative Languages Lets the user describe the problem to be solved in terms of facts and rules. T he user specifies what the problem is, not how to solve it. Are often used to solve logical problems Consists of a database (facts and rules) and an inference engine Have fewer variable types and control structures than procedural languages

11 Prolog Example - Using facts, rules and queries Suppose we want to find out whether a person drives a fast car. We start by building a set of facts and rules for our knowledge base. person(judy). - this is the fact that Judy is a person person(james). drives_car(james,ford_escort). drives_car(judy,porsche). - this is the fact that Judy drives a Porsche drives_fast_car(X):- drives_car(X,Y) and Y = "porsche"

12 Prolog Example - Using facts, rules and queries In this example we could ask the program to tell us whether Judy drives a fast car by typing the query: ?drives_fast_car(judy). The result would be YES since the goal is satisfied.

13 Prolog Example - Using facts, rules and queries If we asked: ?drives_fast_car(james) then the result would be NO as drives_car(james,Y) would evaluate Y="ford escort". This would then cause the rule drives_fast_car(james) to fail as Y does not equal "porsche" and the goal is not satisfied.

14 Declarative Language Examples Lisp Prolog

15 Need for Object Oriented Programming Size of programs makes traditional programming methods unmanageable Difficulty in controlling data flow, especially where global variables involved Even with more modern design techniques, very difficult to make changes to designs of programs once development has started Object Oriented Programming (OOP)

16 Objects Classes Inheritance Encapsulation Polymorphism Object oriented programming concepts

17 Objects are self-contained data structures that consist of properties, methods, and events. – Properties specify the data represented by an object (sometimes called states) – Methods specify an object’s behavior – Events provide communication between objects Objects

18 Think of the person sitting beside you They have properties (name, sex,, height etc) They have methods (sleeping, talking, reading etc) Now think of a button in a VB program It has properties (size, position, text etc) It has methods associated with it (drag, drop, resize etc) Objects

19 Objects are considered as a single unit with both the properties and the methods being integral unlike in traditional programming where the data (properties) is separate from the code that manipulates it (methods) Objects

20 A class defines a blueprint for an object. A class defines how the objects should be built and how they should behave. An object is also known as an instance of a class. Classes

21 Base Class H Computing pupils Sub class Claire Sub class Sam Sub class Craig Here each member of the sub-class shares common features with the base class

22 Inheritance is an OOP feature that allows you to develop a class once, and then reuse that code over and over as the basis of new classes. The class whose functionality is inherited is called a base class. The class that inherits the functionality is called a derived class A derived class can also define additional features that make it different from the base class. Inheritance

23 Properties – Passed Nat 5 Computing In S5 or S6 In School Methods Read English Write English Always does homework Prepared to bribe teacher for a good grade Inheritance Base Class H Computing pupils

24 Inherits all Properties and methods from the base class but can have some of her own Properties Female Methods Listens to music when writing English essays Inheritance Sub class Claire

25 A sub – class (or derived class) will have all the properties and methods of the base class. This makes it easy to edit large programs. If an error is found in a base (or super) class then correcting it there will also correct it in each of the sub-classes Inheritance

26 Objects communicate with each other using events which pass messages from one object to another. There is no direct contact with either the properties or the methods in the objects – the outside can use the properties and methods of an object but cannot change them. This is known as encapsulation Encapsulation

27 Two or more classes derived from a base class are said to be polymorphic. Polymorphism allows two objects to respond to the same method in different ways. In our example, when it is lunchtime, Claire goes to the Fuel Zone while Sam goes to the chip shop. Polymorphism

28 Domain Specific Languages Domain Specific languages are procedural languages designed for a specific task Language will have specific commands and control structures suited to this task These shorten development time and make development easier

29 Domain Specific Languages Examples of domain specific languages HTML – describes the layout and structure of web pages SQL – used for interrogating databases

30 Domain Specific Languages Scripting languages areused to add functionality to existing applications or operating systems Examples Visual Basic for Applications (VBA) – allows users to program additional features into Office programs like Excel and Access Javascript – adds interactivity to web pages

31 Translation software Programs written in a high level language have to be translated into machine code before a computer can execute them Two types of translators for high level languages Interpreters Compilers

32 Translation software Compiler: Translates the program source code into machine code all in one go. Interpreter: Translates the program source code into machine code line by line.

33 Why use an Interpreter? Because it translates the source code line by line, it can tell you if something is wrong with a line as you are writing it Because it translates line by line, it can be used to test parts of a program while it is still being written

34 Disadvantages of an Interpreter You need both the interpreter and the source code every time you run the program Because it needs to be translated every time it is run, the program runs much slower than a compiled program

35 Why use a Compiler? Once translated, the program can be run on any machine which understands that version of machine code. It runs faster than a program which has to be translated line by line every time it is used. No one can see or copy the original program code.

36 Disadvantages of a compiler You need to re-translate a program every time you make a change to it A compiler does not help you understand what is wrong with a program when you are writing and testing it

37 Best of both Worlds! Use an interpreter to write and test your program Use a compiler to translate the source code once it is complete and you are ready to distribute it

38 Programming Tools Text Editor: –Predictive typing –Search and Replace –Highlights Key-words and documentation –Indents code Debugging: –Breakpoints –Watch –Trace

39 Programming Tools Module and class libraries A collection of modules which can be re-used when writing software. A module will include documentation and test results. Save: –Design time –Implementation time –Testing time


Download ppt "Software Design and Development Languages and Environments Computing Science."

Similar presentations


Ads by Google