![Page 1: Lesson 3 –Key featureswiki.computing.hct.ac.uk/_media/computing/btec/level3/l3-u6-lecture_03... · Last session 1. Language generations. 2. Reasons why languages are used by organisations](https://reader033.vdocuments.mx/reader033/viewer/2022041604/5e32e10f29387179f32fccbf/html5/thumbnails/1.jpg)
Lesson 3 – Key features
UNIT 6 - SOFTWARE DESIGN AND DEVELOPMENT
![Page 2: Lesson 3 –Key featureswiki.computing.hct.ac.uk/_media/computing/btec/level3/l3-u6-lecture_03... · Last session 1. Language generations. 2. Reasons why languages are used by organisations](https://reader033.vdocuments.mx/reader033/viewer/2022041604/5e32e10f29387179f32fccbf/html5/thumbnails/2.jpg)
Last session
1. Language generations. 2. Reasons why languages are used by organisations.
1. Proprietary or open source.
2. Features and tools.
3. Availability of trained staff.
4. Reliability.
5. Development and maintenance costs.
6. Expandability
3. IPO
![Page 3: Lesson 3 –Key featureswiki.computing.hct.ac.uk/_media/computing/btec/level3/l3-u6-lecture_03... · Last session 1. Language generations. 2. Reasons why languages are used by organisations](https://reader033.vdocuments.mx/reader033/viewer/2022041604/5e32e10f29387179f32fccbf/html5/thumbnails/3.jpg)
What is covered in this session
Key features of programming languages
![Page 4: Lesson 3 –Key featureswiki.computing.hct.ac.uk/_media/computing/btec/level3/l3-u6-lecture_03... · Last session 1. Language generations. 2. Reasons why languages are used by organisations](https://reader033.vdocuments.mx/reader033/viewer/2022041604/5e32e10f29387179f32fccbf/html5/thumbnails/4.jpg)
Features of programming
Assignment 3 requires you to write a computer program. In order to write this program we need to understand key features of programming. These key features apply to all programming languages.
![Page 5: Lesson 3 –Key featureswiki.computing.hct.ac.uk/_media/computing/btec/level3/l3-u6-lecture_03... · Last session 1. Language generations. 2. Reasons why languages are used by organisations](https://reader033.vdocuments.mx/reader033/viewer/2022041604/5e32e10f29387179f32fccbf/html5/thumbnails/5.jpg)
Features of programming sequence; selection eg
case, if … then … else;
iteration eg repeat – until, while .. do;
variables eg naming conventions, local and global variables,
logical operators; assignment statements; input statements; output statements
![Page 6: Lesson 3 –Key featureswiki.computing.hct.ac.uk/_media/computing/btec/level3/l3-u6-lecture_03... · Last session 1. Language generations. 2. Reasons why languages are used by organisations](https://reader033.vdocuments.mx/reader033/viewer/2022041604/5e32e10f29387179f32fccbf/html5/thumbnails/6.jpg)
Code Structures It is important to have a logical structure to
programs. Programs should be organized so developers
and maintainers can easily determine what modules and routines perform what function.
In procedural paradigms the logical structure follows a top down approach.
![Page 7: Lesson 3 –Key featureswiki.computing.hct.ac.uk/_media/computing/btec/level3/l3-u6-lecture_03... · Last session 1. Language generations. 2. Reasons why languages are used by organisations](https://reader033.vdocuments.mx/reader033/viewer/2022041604/5e32e10f29387179f32fccbf/html5/thumbnails/7.jpg)
Code sequences In all programming languages,
irrespective of programming paradigms, code must be executed in sequence.
One line at a time. This is the order of execution (the
order in which the code runs).
![Page 8: Lesson 3 –Key featureswiki.computing.hct.ac.uk/_media/computing/btec/level3/l3-u6-lecture_03... · Last session 1. Language generations. 2. Reasons why languages are used by organisations](https://reader033.vdocuments.mx/reader033/viewer/2022041604/5e32e10f29387179f32fccbf/html5/thumbnails/8.jpg)
Code sequences
Normal code will run line by line. In VB.NET, the program starts with the public
class. In Scratch, the program starts at the top and
works downwards.
![Page 9: Lesson 3 –Key featureswiki.computing.hct.ac.uk/_media/computing/btec/level3/l3-u6-lecture_03... · Last session 1. Language generations. 2. Reasons why languages are used by organisations](https://reader033.vdocuments.mx/reader033/viewer/2022041604/5e32e10f29387179f32fccbf/html5/thumbnails/9.jpg)
Task 10
Use Visual Studio to – Create a new (Visual Basic) VB.net Windows forms
application name this U06Exercise1. You should have a blank form in the design window. Now do Lab04 part a (only part a). What result did you get?
![Page 10: Lesson 3 –Key featureswiki.computing.hct.ac.uk/_media/computing/btec/level3/l3-u6-lecture_03... · Last session 1. Language generations. 2. Reasons why languages are used by organisations](https://reader033.vdocuments.mx/reader033/viewer/2022041604/5e32e10f29387179f32fccbf/html5/thumbnails/10.jpg)
Selection statementsSelection is about decision making in your code. break the line-by-line reading tell the program to jump to another section. An example of this would be an IF statement. In VB.NET, you can make use of ‘for’ loops and ‘if’
statements. In Scratch, you can also use loops if a criteria is/isn’t
true.
![Page 11: Lesson 3 –Key featureswiki.computing.hct.ac.uk/_media/computing/btec/level3/l3-u6-lecture_03... · Last session 1. Language generations. 2. Reasons why languages are used by organisations](https://reader033.vdocuments.mx/reader033/viewer/2022041604/5e32e10f29387179f32fccbf/html5/thumbnails/11.jpg)
Selection statements
If statements check for a true condition and then execute the dependant statements.
If a = b then….. End if
Is this true?
If so, do this!
![Page 12: Lesson 3 –Key featureswiki.computing.hct.ac.uk/_media/computing/btec/level3/l3-u6-lecture_03... · Last session 1. Language generations. 2. Reasons why languages are used by organisations](https://reader033.vdocuments.mx/reader033/viewer/2022041604/5e32e10f29387179f32fccbf/html5/thumbnails/12.jpg)
Selection statements
What do these statements do? 1. If x > 0 and x < 5 then
Console.writeline(x.tostring) End if
2. If x > 0 then if x < 5 then
Console.writeline(x.tostring) End if
End if
![Page 13: Lesson 3 –Key featureswiki.computing.hct.ac.uk/_media/computing/btec/level3/l3-u6-lecture_03... · Last session 1. Language generations. 2. Reasons why languages are used by organisations](https://reader033.vdocuments.mx/reader033/viewer/2022041604/5e32e10f29387179f32fccbf/html5/thumbnails/13.jpg)
Selection statements - Task
Add a button to your form named “btnSelection”, the text should say “Selection” Add a numericupdown control named “numNumber”. Change its max value property to 100. Now do Lab04 Part b. Make sure you add comments to the code.
![Page 14: Lesson 3 –Key featureswiki.computing.hct.ac.uk/_media/computing/btec/level3/l3-u6-lecture_03... · Last session 1. Language generations. 2. Reasons why languages are used by organisations](https://reader033.vdocuments.mx/reader033/viewer/2022041604/5e32e10f29387179f32fccbf/html5/thumbnails/14.jpg)
Case statements
An alternative way to code multipleIf/elseifStatements.
![Page 15: Lesson 3 –Key featureswiki.computing.hct.ac.uk/_media/computing/btec/level3/l3-u6-lecture_03... · Last session 1. Language generations. 2. Reasons why languages are used by organisations](https://reader033.vdocuments.mx/reader033/viewer/2022041604/5e32e10f29387179f32fccbf/html5/thumbnails/15.jpg)
Case statements. Example of If/elseif
If x = 0 then console.writeline(x.tostring())
Elseif x = 1 then console.writeline(x.tostring())
Elseif x = 2 then console.writeline(x.tostring())
etc
![Page 16: Lesson 3 –Key featureswiki.computing.hct.ac.uk/_media/computing/btec/level3/l3-u6-lecture_03... · Last session 1. Language generations. 2. Reasons why languages are used by organisations](https://reader033.vdocuments.mx/reader033/viewer/2022041604/5e32e10f29387179f32fccbf/html5/thumbnails/16.jpg)
Example of If/elseif replaced with case.
Select Case x Case 0
console.writeline(x.tostring()) Case 1
console.writeline(x.tostring()) Case 2
console.writeline(x.tostring()) End Select
This is easier to read and maintain.
![Page 17: Lesson 3 –Key featureswiki.computing.hct.ac.uk/_media/computing/btec/level3/l3-u6-lecture_03... · Last session 1. Language generations. 2. Reasons why languages are used by organisations](https://reader033.vdocuments.mx/reader033/viewer/2022041604/5e32e10f29387179f32fccbf/html5/thumbnails/17.jpg)
Case statements - Task
Add a button to your form named “btnCase”, the text on the button should read “Case”. Do Lab04 Part c. Comment the code. Is this code easier to read than that in part b?
![Page 18: Lesson 3 –Key featureswiki.computing.hct.ac.uk/_media/computing/btec/level3/l3-u6-lecture_03... · Last session 1. Language generations. 2. Reasons why languages are used by organisations](https://reader033.vdocuments.mx/reader033/viewer/2022041604/5e32e10f29387179f32fccbf/html5/thumbnails/18.jpg)
Recap
sequence; selection eg
case,
if … then … else;
ParadigmsChoice of languagesKey features of programming languages
Visual studio
‘comments
![Page 19: Lesson 3 –Key featureswiki.computing.hct.ac.uk/_media/computing/btec/level3/l3-u6-lecture_03... · Last session 1. Language generations. 2. Reasons why languages are used by organisations](https://reader033.vdocuments.mx/reader033/viewer/2022041604/5e32e10f29387179f32fccbf/html5/thumbnails/19.jpg)
Now we will cover
iteration eg repeat – until, while .. do;
Data typesAssignment 1b
variables eg naming
conventions, local and global
variables, logical operators;
assignment statements;
input statements; output statements
![Page 20: Lesson 3 –Key featureswiki.computing.hct.ac.uk/_media/computing/btec/level3/l3-u6-lecture_03... · Last session 1. Language generations. 2. Reasons why languages are used by organisations](https://reader033.vdocuments.mx/reader033/viewer/2022041604/5e32e10f29387179f32fccbf/html5/thumbnails/20.jpg)
Iteration statements. (Loops)
Iteration in computing is the repetition of a block of statements within a computer program. Two types of loop. Fixed loops –
a sequence of statements is executed a fixed number of times.
Dim ant as int32 = 0
For ant = 0 to 5
….. Do something
Loop
An assignment statement
![Page 21: Lesson 3 –Key featureswiki.computing.hct.ac.uk/_media/computing/btec/level3/l3-u6-lecture_03... · Last session 1. Language generations. 2. Reasons why languages are used by organisations](https://reader033.vdocuments.mx/reader033/viewer/2022041604/5e32e10f29387179f32fccbf/html5/thumbnails/21.jpg)
Iteration statements. (Loops)
The second type is a loop which continues until a condition is met or continues while a condition is true.Do while x > 0 and x < 5 …. Loop Example of a pre-check loop
condition
![Page 22: Lesson 3 –Key featureswiki.computing.hct.ac.uk/_media/computing/btec/level3/l3-u6-lecture_03... · Last session 1. Language generations. 2. Reasons why languages are used by organisations](https://reader033.vdocuments.mx/reader033/viewer/2022041604/5e32e10f29387179f32fccbf/html5/thumbnails/22.jpg)
Loops - Task
Add a button to your form named “btnLoop”, the text on the button should read “Loop”.
Do Lab04 Part d. Comment the code.
![Page 23: Lesson 3 –Key featureswiki.computing.hct.ac.uk/_media/computing/btec/level3/l3-u6-lecture_03... · Last session 1. Language generations. 2. Reasons why languages are used by organisations](https://reader033.vdocuments.mx/reader033/viewer/2022041604/5e32e10f29387179f32fccbf/html5/thumbnails/23.jpg)
Increment/decrement statements
Consider these statements –Dim x as int32 = 0 x = x + 1 what is the value of x?
As an alternative we could do this –x++
this produces the same result as the line above. However, it only increments by 1.
![Page 24: Lesson 3 –Key featureswiki.computing.hct.ac.uk/_media/computing/btec/level3/l3-u6-lecture_03... · Last session 1. Language generations. 2. Reasons why languages are used by organisations](https://reader033.vdocuments.mx/reader033/viewer/2022041604/5e32e10f29387179f32fccbf/html5/thumbnails/24.jpg)
Increment/decrement statements
Consider these statements –Dim x as int32 = 0 x = x - 1 what is the value of x?
As an alternative we could do this –x--
this produces the same result as the line above. However, it only decrements by 1.
![Page 25: Lesson 3 –Key featureswiki.computing.hct.ac.uk/_media/computing/btec/level3/l3-u6-lecture_03... · Last session 1. Language generations. 2. Reasons why languages are used by organisations](https://reader033.vdocuments.mx/reader033/viewer/2022041604/5e32e10f29387179f32fccbf/html5/thumbnails/25.jpg)
Increment/decrement statements
Consider these statements –Dim x as int32 = 12 x = x + 1 what is the value of x?
As an alternative we could do this –x++
this produces the same result as the line above. It still only increments by 1.
![Page 26: Lesson 3 –Key featureswiki.computing.hct.ac.uk/_media/computing/btec/level3/l3-u6-lecture_03... · Last session 1. Language generations. 2. Reasons why languages are used by organisations](https://reader033.vdocuments.mx/reader033/viewer/2022041604/5e32e10f29387179f32fccbf/html5/thumbnails/26.jpg)
Assignment statements
Assign values to variables use = or := E.g. myVariable = 20
Can be combined with mathematical operator E.g. myVariable = 20 + subtotal
![Page 27: Lesson 3 –Key featureswiki.computing.hct.ac.uk/_media/computing/btec/level3/l3-u6-lecture_03... · Last session 1. Language generations. 2. Reasons why languages are used by organisations](https://reader033.vdocuments.mx/reader033/viewer/2022041604/5e32e10f29387179f32fccbf/html5/thumbnails/27.jpg)
Mathematical Operators
myVariable = 20 + 2 * 3 What answer will this produce? Why? BIDMAS
Operator Meaning Example Precedence^ Exponentiation 2^3=8 1/ Division 10/2=5 2* Multiplication 2*3=6 3Mod Modular arithmetic
(remainders)5(mod)2=1 4
+ Addition 4+5=9 5- subtraction 7-4=3 6
![Page 28: Lesson 3 –Key featureswiki.computing.hct.ac.uk/_media/computing/btec/level3/l3-u6-lecture_03... · Last session 1. Language generations. 2. Reasons why languages are used by organisations](https://reader033.vdocuments.mx/reader033/viewer/2022041604/5e32e10f29387179f32fccbf/html5/thumbnails/28.jpg)
Input and output statements
In visual programming input and output usually accomplished by controls. List boxes; text boxes; buttons
Procedures collect values entered into boxesE.g. MyText = txtMyInput.text
variable textbox
![Page 29: Lesson 3 –Key featureswiki.computing.hct.ac.uk/_media/computing/btec/level3/l3-u6-lecture_03... · Last session 1. Language generations. 2. Reasons why languages are used by organisations](https://reader033.vdocuments.mx/reader033/viewer/2022041604/5e32e10f29387179f32fccbf/html5/thumbnails/29.jpg)
Input and output statements
Similarly for output Procedures enter values into boxesE.g. lblMyLabel.text = myText
String value could also be used.
label variable
![Page 30: Lesson 3 –Key featureswiki.computing.hct.ac.uk/_media/computing/btec/level3/l3-u6-lecture_03... · Last session 1. Language generations. 2. Reasons why languages are used by organisations](https://reader033.vdocuments.mx/reader033/viewer/2022041604/5e32e10f29387179f32fccbf/html5/thumbnails/30.jpg)
Summary
So what have you learnt so far?
Next we will look at variables in more detail.