210 likes | 332 Vues
Sending and receiving devices. Term 2, 2011 Week 1. CONTENTS. Problem-solving methodology Programming and scripting languages Programming languages Scripting languages Features of programming and scripting languages Objects and properties, events and actions Storing and using data
E N D
Sending and receiving devices Term 2, 2011 Week 1
CONTENTS • Problem-solving methodology • Programming and scripting languages • Programming languages • Scripting languages • Features of programming and scripting languages • Objects and properties, events and actions • Storing and using data • Strings • Decimal numbers • Precision problems with financial and scientific data • Arrays • Images, sounds and videos • Processing structures and commands • Control structures • Sequence • Selection • Iteration • Questions
Problem-solving methodology • Four stages: analysis, design, development and evaluation. • For this area of study you will be required to produce solutions to information problems using programming language.
Programming and scripting languages • Manipulating data to produce solutions for clients often cannot be performed with standard software such as spreadsheets. • Clients usually need to have the solution built to serve their own purposes (usually to inform, persuade, educate or entertain). • Purpose-designed software solutions are usually produced using a general-purpose programming language that allows both for the manipulation of objects and data and for various types of input and output.
Programming languages • The main features of PL’s that differentiate them from scripting languages are the ability to handle more varied types of data easily, to do more complicated processing, and to process larger amounts of data. • Information is easily manipulated with the use of arrays, which can be thought of as tables of data, and other complex data structures.
PL’s lack ready-built standard interfaces for input and output. This means they are more flexible in the range of solutions that can be produced, but can also mean it is more time and effort consuming to create a useful product. • This is why user interfaces are often programmed using a scripting language, and complex data processing is performed using a general purpose PL.
Scripting languages • SL is a PL that is designed to program within a particular application, or embedded within another application to provide extra functionality. E.g. ActionScript is used to program Flash animations, JavaScript is embedded into webpages. • Has simpler syntax and fewer programming constructs than a PL as it is limited by the features of the host application.
Scripting does not usually require complicated coding (usually no more than 5-10 lines because it only has one main function). • Can be to send a user to another screen depending on some condition, to perform a simple calculation, to validate some input, to change an attribute etc. • Script is often attached to an object already in the application, such as a button or object.This can often mean that all coding is not in the same location as it is with a PL; this can create problems keeping track of extensive amounts of scripting code. • Using a SL means that much of the user interface does not need to be built, saving time and effort.
Features of programming and scripting languages • A programming or scripting language is a method of communicating instructions to a computer. Each has a set of formal specifications regarding the use of objects, key words and commands in the language. This language enables a programmer to specify: • What actions or processing will be performed under various circumstances within the program • How the data will be stored in the computer • Exactly what type of data will be processed.
Objects and properties, events and actions • Programming and scripting languages often have a range of objects that can be manipulated using a mouse, such as buttons, labels, images and drawings. • These objects have various properties, associated events and actions. This object-oriented type of programming was invented to allow the developer to build a solution easily. • Many of these objects are common to applications and are increasingly in general programming languages.
Often familiar to the user and have easy-to-change visual properties (i.e. Colour, size and position). Have familiar events and actions attached (mouse click, mouse hover etc.). • Each type of language has objects with properties and associated actions>often similar, yet different. Usually a greater range of objects in a PL. • Languages support various types of data formats, structures and objects, and these are manipulated using a variety of programming structures and commands.
Storing and using data • Data and information are stored in a computer-based solution in various ways. • Main type of storage are variables (or memory locations) that usually only hold one item of data; more complex variable structures, such as lists, arrays and database tables that hold more than one item; and some data held in the visual and non-visual properties of objects. Some data may need to be stored in a file on a hard disk when the application is closed.
Each variable has a number of properties: • Name of the variable • Type of data stored in the variable • Amount or size of the data • The data stored in variables (working data) is needed as the applications are executed. • Variables usually need to be declared so that the program knows how much data needs to be stored in the memory location, the type of data and the size of the data. • When developing purpose-built solutions, various types of data need to be entered, stored, manipulated/processed for output.
Numbers may need to be entered and there may be whole numbers, decimals, dates and true/false (Boolean) information. • The data may need to be stored as constant values in the solution which do not usually change, such as the cost of a product or a percentage discount. • All data is stored in digital format as binary digits. The size of the fundamental group is 8 bits (i.e. ‘5’ is stored as ‘00000101’).
Strings • Sequences of characters and used to store words. • Different languages allow different lengths of string. • A string length of 255 characters is a common maximum length. • Can be operated on as whole words, sentences, or as individual characters. Individual characters within a string can be processed using an index number. • Compared on a letter-by-letter basis, checking the first character, then the next and so on.
Decimal numbers • Numbers that include a fractional or decimal part. Split into the mantissa and the exponent. • The mantissa holds all of the digits with a decimal point after the first digit. • The exponent holds the power of ten by which the mantissa must be multiple to regain original number. • Also called real numbers, floating point numbers and double numbers in some languages.
Precision problems with financial and scientific data • Where financial or scientific data is entered, it is stored as a decimal value and formatted as the user selects (e.g. Price could be stored as 45.3426000 and formatted for output as $45.34. • The extra decimal places need to be carefully programmed to ensure errors don’t occur when they are rounded off.
Arrays • Can be more than one-dimensional. Two-dimensional arrays, such as player names and scores, are like tables or matrices of data with two indexes corresponding to the position down and across the table (like a spreadsheet). • Any two-dimensional item, such as a screen or board game layout, can use a matrix to represent data. • Can be referenced by Row = 3, Col = 2
Images, sounds and videos • Programming and scripting languages can also use images, sounds and videos. Image, sound and video data are stored in standard formats/ • They are usually imported into a container object that has properties such as size, position and coloured borders. Changing the size of the object container changes the image size automatically. • Data is stored in binary form, but what that data actually represents depends on the program that is accessing the data.
Different programs interpret the data differently, hence why opening a file in another program can show some strange results. • Colours are the main components of images and are represented as pixels on a screen using RGB or CMYK systems.
Questions • What is a programming and scripting language? • What is the difference between a general-purpose and a scripting programming language? • What are the two main components of a programming or scripting language? • What is object-oriented programming? • What is a variable? • Explain character, string and Boolean variables. • What is an array? • List some common formats of images and sounds.