Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Charlie Love
Education Support Officer
Aberdeen City Council
@charlie_love
Software development using Server-
side scripting
• an integrated approach to Higher Computing
Science.
• approaches to in...
Higher Computing Science
Software Design
and
Development
Information
Systems Design
and
Development
Assessment
Assessment
Information
Systems Design
and Development
Software Design
and Development Integrating the delivery of
units us...
Using *AMP stack
+ ++
Get *AMP on your computers
• Education Scotland Blog post with information
• http://glo.li/edscot-amp
• MAMP
• EasyPHP
• X...
Building solutions
• Agile methodologies
• Interative prototyping
• Design->Build->Test->Repeat
• Working code
• Limited F...
sub-programs/routines
defined by their name and arguments (inputs
and outputs)
• PHP uses functions which typically return...
including parameter passing (value
and reference, formal and actual)
function read_users( $file, &$user_id, &$user_name,
&...
methods
• methods are subroutines associated with an
object
• they have access to the objects data.
• PHP includes support...
If ($result = $mysqli->query
("SELECT * FROM user WHERE user_id = '" .
$login_user_id . "'"))
{
$obj = $result->fetch_obje...
Data types and structures
• string
• numeric
(integer and real)
• Boolean
$mysting=“Some
text”;
$integer = 12;
$real =15.2...
• Records - Implement as an array of objects
class Owner
{
public $year;
public $measure;
public $month;
public $name;
}
$...
• sequential files (open, create, read, write,
close)
• fopen(filename, mode)
– Creates and/or opens file
– Mode is read a...
Standard Algorithms
• input validation (server side) / server-side
validation of online form data
– Set up form in html
– ...
<?php
$username="”;
if (isset($_GET[’username'])) {
$error_found = false;
$message = "username is accepted”;
$username = $...
Linear search
• linear search
function linear_search($needle, $haystack) {
for($i = 0; $i < count($haystack); $i++) {
if (...
Finding minimum and maximum
Inbuilt max and min functions do it out of the box
function findmax($array_of_values) {
$curre...
count occurrences
function count_values($val_to_count, $array_of_values) {
$counter = 0;
for($i = 0; $i < count($array_of_...
Coding (ISDD)
• scripting (database/web pages)
• client-side scripting
• server-side scripting
• server-side validation of...
Structures and Links (Database)
• MySQL
• phpMyAdmin - Database front end
– Can be used to generate SQL for coding
– Web b...
Structures and Links (Web)
• PHP, HTML, CSS, JavaScript all play well together
<html>
<head>
<title><?php echo $title;></t...
PHP and MySQL
//connect to the database using mysqli API
$mysqli = new mysqli("localhost", "root", "root",
”mydatabase");
...
Run a query and retrieve results
if ($result = $mysqli->query("SELECT * FROM my_table
WHERE field_id = '" . $field_id . "'...
Write to the database
$sql = mysqli('localhost','user','password','database');
$name = $_POST['name'];
$age = $_POST['age'...
Relationships in MySQL
Implemented using queries
SELECT * FROM table1, table2
WHERE table2.id = table1.hid
id field
12 Har...
Search in MySQL
Implemented using queries
SELECT * FROM table1, table2
WHERE table1.id = 12;
SELECT * FROM table1, table2
...
Assessment
• You need to show that the candidate has
achieve all the Assessment Standards
• SDD Outcome 2 and ISDD Outcome...
Higher Assignment
• Assignment 1: Coding + Database (Diving
Championship – available now)
• Assignment 2: Server Side Scri...
Blog: http://charlielove.org
Twitter: @charlie_love
Amp and higher computing science
Amp and higher computing science
Upcoming SlideShare
Loading in …5
×

Amp and higher computing science

1,746 views

Published on

My slides from Education Scotland's Computing Science Conference on 29th May.

Published in: Education, Technology
  • Be the first to comment

  • Be the first to like this

Amp and higher computing science

  1. 1. Charlie Love Education Support Officer Aberdeen City Council @charlie_love
  2. 2. Software development using Server- side scripting • an integrated approach to Higher Computing Science. • approaches to increase teaching time • reduce the assessment • strategies for integrated delivery blending components of the SDD and ISDD units • use contemporary web technologies: Apache/Mysql/PHP/JavaScript
  3. 3. Higher Computing Science Software Design and Development Information Systems Design and Development Assessment
  4. 4. Assessment Information Systems Design and Development Software Design and Development Integrating the delivery of units using a server side scripting language will increase teaching time and decrease time take for assessment
  5. 5. Using *AMP stack + ++
  6. 6. Get *AMP on your computers • Education Scotland Blog post with information • http://glo.li/edscot-amp • MAMP • EasyPHP • XAMMP • WAMP • etc.
  7. 7. Building solutions • Agile methodologies • Interative prototyping • Design->Build->Test->Repeat • Working code • Limited Feature Set -> Expanded Feature Set
  8. 8. sub-programs/routines defined by their name and arguments (inputs and outputs) • PHP uses functions which typically return a single value. • Use of &parameter passes values by reference to the PHP function (essentially creating a subprogram)
  9. 9. including parameter passing (value and reference, formal and actual) function read_users( $file, &$user_id, &$user_name, &$user_image, &$password_string, $index ) { $textline = fgets($file); $textarray = explode(',',$textline); $user_id[$index] = trim($textarray[0]) $user_name[$index] = trim($textarray[1]); $user_image[$index] = trim($textarray[2]); $password_string[$index] = trim($textarray[3]); }
  10. 10. methods • methods are subroutines associated with an object • they have access to the objects data. • PHP includes support for object oriented programming • Use the MySQL API to show methods on database objects
  11. 11. If ($result = $mysqli->query ("SELECT * FROM user WHERE user_id = '" . $login_user_id . "'")) { $obj = $result->fetch_object(); $user_id = $obj->user_id; $user_name = $obj->user_name; $user_image = $obj->user_image; $result->close();}
  12. 12. Data types and structures • string • numeric (integer and real) • Boolean $mysting=“Some text”; $integer = 12; $real =15.232; $is_set = true;
  13. 13. • Records - Implement as an array of objects class Owner { public $year; public $measure; public $month; public $name; } $names = array('Lars', 'James', 'Kirk', 'Robert'); for ($i = 1 ; $i <= 3 ; $i++) { $owner = new Owner(); $owner->year = 2012; $owner->measure = $i; $owner->month = rand(1,12); $owner->name = array_rand($names); $owners[] = $owner; }
  14. 14. • sequential files (open, create, read, write, close) • fopen(filename, mode) – Creates and/or opens file – Mode is read and/or write and moves file pointer to start or end of file. – http://www.php.net/manual/en/function.fopen.p hp • fwrite($file, $textline); – $file is the file handle from opening the file – $textline is the line of text to be written • fgets($file) – Reads line of text from the file • fclose($file) – close file
  15. 15. Standard Algorithms • input validation (server side) / server-side validation of online form data – Set up form in html – Process and validate form on submission – Processing happens at server – User interaction is required to create validation loop
  16. 16. <?php $username="”; if (isset($_GET[’username'])) { $error_found = false; $message = "username is accepted”; $username = $_GET[’username’]; if(strlen($username) < 8 ) { $error_found = true; $message = “Enter 8 or more characters”; } echo "<div>" . $message . "</div>"; } if (($error_found) || (!isset($error_found))) { //show form if err found or 1st visit ?> <form action="<?php echo $_SERVER[‘PHP_SELF’];?>" method="get"> <input type="text" name="username" value="<?php echo $username;?>"> <input type="submit" value="Submit" name="update"/> </form> <? php } ?>
  17. 17. Linear search • linear search function linear_search($needle, $haystack) { for($i = 0; $i < count($haystack); $i++) { if ($needle == $i) return true; } return false; } $haystack = array(1,2,3,4); $needle = 3; $found = linear_search($needle, $haystack);
  18. 18. Finding minimum and maximum Inbuilt max and min functions do it out of the box function findmax($array_of_values) { $current_max = $array_of_values[0]; for($i = 1; $i < count($array_of_values); $i++) { if ($array_of_values[$i] > $current_max) { $current_max = $array_of_values[$i]; } } return $current_max; } $my_array= array(12,25,23,14); $biggest_number = findmax($my_array);
  19. 19. count occurrences function count_values($val_to_count, $array_of_values) { $counter = 0; for($i = 0; $i < count($array_of_values); $i++) { if ($array_of_values[$i] == $val_to_count) { $counter++; } } return $counter; } $my_array= array(12,25,23,14,72,83,12,12,63,25,14); $count_of_values = count_values(12, $my_array);
  20. 20. Coding (ISDD) • scripting (database/web pages) • client-side scripting • server-side scripting • server-side validation of online form data
  21. 21. Structures and Links (Database) • MySQL • phpMyAdmin - Database front end – Can be used to generate SQL for coding – Web based – simplifies database management
  22. 22. Structures and Links (Web) • PHP, HTML, CSS, JavaScript all play well together <html> <head> <title><?php echo $title;></title> <style> hr {color:sienna;} p {margin-left:20px;} body {background-image:url(“bg.gif");} </style> <script> function show_message() { alert(“hello there”); } </script> <body onLoad=“show_message();”> ….
  23. 23. PHP and MySQL //connect to the database using mysqli API $mysqli = new mysqli("localhost", "root", "root", ”mydatabase"); if ($mysqli->connect_errno) { echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error; die; }
  24. 24. Run a query and retrieve results if ($result = $mysqli->query("SELECT * FROM my_table WHERE field_id = '" . $field_id . "'")) { $obj = $result->fetch_object(); $my_field_id = $obj->field_id; $my_field1 = $obj->field1; $my_field2 = $obj->field2; /* free result set */ $result->close(); }
  25. 25. Write to the database $sql = mysqli('localhost','user','password','database'); $name = $_POST['name']; $age = $_POST['age']; $email = $_POST['email']; $query = $sql->prepare("INSERT INTO `tablename` VALUES ('?','?','?');"); $query->bind_param("sis",$name,$age,$email); $query->execute();
  26. 26. Relationships in MySQL Implemented using queries SELECT * FROM table1, table2 WHERE table2.id = table1.hid id field 12 Harry 13 Sally 14 Joe 15 Kirsty id field hid 3232 sweets 12 3233 candy 12 3234 chocolate 12 3235 popcorn 13 3236 soup 13 table1 table2
  27. 27. Search in MySQL Implemented using queries SELECT * FROM table1, table2 WHERE table1.id = 12; SELECT * FROM table1, table2 WHERE table1.field LIKE “%Joe%” AND WHERE table2.id = table1.hid ;
  28. 28. Assessment • You need to show that the candidate has achieve all the Assessment Standards • SDD Outcome 2 and ISDD Outcome 1 can be assessed in the same exercise • Alternative evidence can be gathered as part of learning and teaching • SDD Outcome 1 for part of this as well
  29. 29. Higher Assignment • Assignment 1: Coding + Database (Diving Championship – available now) • Assignment 2: Server Side Scripting – File handling – Linear Search – Server side scripting – Online database integration • Assignment 3: Client Side Scripting – CSS – Browser based
  30. 30. Blog: http://charlielove.org Twitter: @charlie_love

×