Programming For Designers V3
Upcoming SlideShare
Loading in...5
×
 

Programming For Designers V3

on

  • 1,785 views

 

Statistics

Views

Total Views
1,785
Views on SlideShare
1,785
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Programming For Designers V3 Programming For Designers V3 Presentation Transcript

  • Overcoming code fear
      • An introduction to programming for designers
  • Unintelligible - Yuk
    • ^[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}$
  • But not all code is squiggles!
    • SUBTRACT Tax FROM GrossPay GIVING NetPay
    View slide
  • So what is a script?
    • A script for a play defines a cast and gives them instruction to produce the desired result, a play.
    • A script for a computer could be said to be the same. It defines the resources and how they are used in a prescriptive manner to achieve a desired result. The words script and program can be used interchangeably.
    View slide
  • Languages
    • BASIC, C++, Java, JavaScript, Lisp, SQL, PHP, Perl, Python, Ruby
    • Why is HTML not considered a programming language?
    • Why is ASP not on this list?
    • Learn one language and you have learned a lot about many others.
  • A standard HTTP request Request hello.HTML Browser Server hello.HTML <h1>Hello</h1> goodbye.HTML <h1>Hello</h1>
  • A standard HTTP request Response Browser Server hello..HTML <h1>Hello</h1> goodbye.HTML <h1>Bye</h1> <h1>Hello</h1>
  • A standard HTTP request Hello
  • A CGI Request Request hello. PHP Browser Server hello.PHP Echo “Hello”; goodbye.PHP Echo “Goodbye”;
  • A CGI Request Response hello.PHP Echo “Hello”; Browser Server goodbye.PHP Echo “Goodbye”; <h1>Hello</h1>
  • A CGI Request hello.PHP <?php echo “ <h1>Hello</h1> ”; ?>
  • A CGI Request Hello
  • Server Side vs Client Side Javascript Java Flash PHP Java ASP Client Server HTTP
  • Sequences
    • echo “<p>Hello</p>” ;
    • echo “<p>Goodbye</p>” ;
    • To Do:
    • Go Home
    • Make Tea
    • Wash Up
    To Do:
  • Variables Name Price John 16.50
  • Variables Name Price Pete 16.50
  • Variables
    • $ price = 20;
    • $ name = “John”;
    • echo “Hello $ name, the price is £ $ price”;
    • $ name = “Pete”;
    • echo “Hello $ name, the price is £ $ price”;
    • $ tax = $ price * 0.15;
  • Input A PHP script Get Post Database Cookies Files Server Info To Do:
  • Output A PHP script HTML Database Cookies Files To Do:
  • Hello $name
    • $name = $_REQUEST[‘your_name’] ;
    • echo “<p>Hello $name </p>”;
    helloform.HTML … … … <form action=“ helloreply.php ” method=“post”> <label>Your Name</label> <input type=“text” name=“your_name” /> <input type=“submit” /> </form> … … … helloreply.PHP <html> <head>…..</head> <body> <?php $name = $_REQUEST[‘your_name’]; echo “<p>Hello $name</p>” ; ?> </body> <html>
  • Expressions and operators
    • $counter + 1;
    • ($quantity * $price) + $shipping
    • “ blue” . “bird”
    • 1 < 2
    • $dog == “Spot”
    • $price != 44;
  • Selection – Hello maybe
    • $name = “Martin”;
    • if ($name != “John”)
    • {
    • echo “Hello!”;
    • }
    • else
    • {
    • echo “Goodbye!”;
    • }
    To Do: Plan for today if it is hot then go outside otherwise stay in bed
  • A more useful Hello maybe
    • $name = $_REQUEST[‘your_name’];
    • if ($name != “Pete”)
    • {
    • echo “Hello!”;
    • }
    • else
    • {
    • echo “Goodbye!”;
    • }
    • hello.php?your_name=Mary
    • hello.php?your_name=Pete
  • Repetition (looping)
    • run a lap
    • until done 100 laps or completely knackered
    • $counter = 1;
    • while ( $counter <= 10 )
    • {
    • echo “$counter <br />”;
    • $counter = $counter + 1;
    • }
    • echo “Finished<br />”;
  • Functions
    • function fill_kettle ()
    • {
      • place kettle under tap;
      • turn on tap;
      • wait until kettle is full;
      • turn off tap;
    • }
    • fill_kettle ();
  • Hello function
    • hello();
      • function hello()
      • {
        • $name = $_REQUEST[‘name’];
        • echo “<p>Hello $name</p>”;
      • }
  • Hello parameter
    • <?php
    • welcome( “Jane” );
    • welcome($somebody);
      • function welcome( $name )
      • {
        • $message = “<p>Hello $name</p>”;
        • echo $message;
      • }
    • ?>
  • Databases
    • Databases need code to retrieve data and translate into HTML
    • SQL is the most popular language for asking databases for data
    • PHP can talk to many databases using SQL but most often is paired with MySQL
  • SQL
    • SQL is used with other languages such as PHP
    • SELECT * FROM orders;
    • SELECT profile_pic FROM profiles WHERE profile_name = “Jimbo123”;
  • Let’s Design an App Twaddl.com What have you done today? Update Cooked a curry Went to work Jogged 2 miles
  • Twaddl Database ID Twaddl 1 Argued with girlfriend – again! 3 Went to work 4 Cooked a curry 2 Jogged 2 miles
  • Twaddl Main Program Flow Handle posted twaddl List twaddles
  • Handle Posted Twaddl Is submitted twaddle empty? Insert twaddle into database List twaddles No Yes Display an error message
  • List Twaddles Get list of twaddles from database End Program For each twaddle in list: Display twaddle
  • Complications! An example.
    • Ordinals: 1 st 2 nd 3 rd 4 th etc.
    • Mod: 53 % 10
    • function ordinal($number)
    • {
    • $last_digit = $number % 10;
    • if ($last_digit == 1) $ord = “st”;
    • elseif ($last_digit == 2) $ord = “nd”;
    • elseif ($last_digit == 3) $ord = “rd”;
    • else $ord = “th”;
    • echo $number . $ord;
    • }
  • Where from here?
    • PHP Lessons Online:
    • http://uk3. php .net/ tut . php
    • http://www. webmonkey .com/tutorial/PHP_Tutorial_for_Beginners
    • Tuition 