Programming For Designers V3

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Favorites, Groups & Events

    Programming For Designers V3 - Presentation Transcript

    1. Overcoming code fear
        • An introduction to programming for designers
    2. Unintelligible - Yuk
      • ^[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}$
    3. But not all code is squiggles!
      • SUBTRACT Tax FROM GrossPay GIVING NetPay
    4. 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.
    5. 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.
    6. A standard HTTP request Request hello.HTML Browser Server hello.HTML <h1>Hello</h1> goodbye.HTML <h1>Hello</h1>
    7. A standard HTTP request Response Browser Server hello..HTML <h1>Hello</h1> goodbye.HTML <h1>Bye</h1> <h1>Hello</h1>
    8. A standard HTTP request Hello
    9. A CGI Request Request hello. PHP Browser Server hello.PHP Echo “Hello”; goodbye.PHP Echo “Goodbye”;
    10. A CGI Request Response hello.PHP Echo “Hello”; Browser Server goodbye.PHP Echo “Goodbye”; <h1>Hello</h1>
    11. A CGI Request hello.PHP <?php echo “ <h1>Hello</h1> ”; ?>
    12. A CGI Request Hello
    13. Server Side vs Client Side Javascript Java Flash PHP Java ASP Client Server HTTP
    14. Sequences
      • echo “<p>Hello</p>” ;
      • echo “<p>Goodbye</p>” ;
      • To Do:
      • Go Home
      • Make Tea
      • Wash Up
      To Do:
    15. Variables Name Price John 16.50
    16. Variables Name Price Pete 16.50
    17. 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;
    18. Input A PHP script Get Post Database Cookies Files Server Info To Do:
    19. Output A PHP script HTML Database Cookies Files To Do:
    20. 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>
    21. Expressions and operators
      • $counter + 1;
      • ($quantity * $price) + $shipping
      • “ blue” . “bird”
      • 1 < 2
      • $dog == “Spot”
      • $price != 44;
    22. 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
    23. 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
    24. 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 />”;
    25. Functions
      • function fill_kettle ()
      • {
        • place kettle under tap;
        • turn on tap;
        • wait until kettle is full;
        • turn off tap;
      • }
      • fill_kettle ();
    26. Hello function
      • hello();
        • function hello()
        • {
          • $name = $_REQUEST[‘name’];
          • echo “<p>Hello $name</p>”;
        • }
    27. Hello parameter
      • <?php
      • welcome( “Jane” );
      • welcome($somebody);
        • function welcome( $name )
        • {
          • $message = “<p>Hello $name</p>”;
          • echo $message;
        • }
      • ?>
    28. 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
    29. SQL
      • SQL is used with other languages such as PHP
      • SELECT * FROM orders;
      • SELECT profile_pic FROM profiles WHERE profile_name = “Jimbo123”;
    30. Let’s Design an App Twaddl.com What have you done today? Update Cooked a curry Went to work Jogged 2 miles
    31. Twaddl Database ID Twaddl 1 Argued with girlfriend – again! 3 Went to work 4 Cooked a curry 2 Jogged 2 miles
    32. Twaddl Main Program Flow Handle posted twaddl List twaddles
    33. Handle Posted Twaddl Is submitted twaddle empty? Insert twaddle into database List twaddles No Yes Display an error message
    34. List Twaddles Get list of twaddles from database End Program For each twaddle in list: Display twaddle
    35. 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;
      • }
    36. Where from here?
      • PHP Lessons Online:
      • http://uk3. php .net/ tut . php
      • http://www. webmonkey .com/tutorial/PHP_Tutorial_for_Beginners
      • Tuition 

    + sqoosqoo, 11 months ago

    custom

    238 views, 0 favs, 0 embeds more stats

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 238
      • 238 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 0
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories