RU beehive logo ITEC dept promo banner
ITEC 325
2012spring
ibarland

homelectsexamshws
D2Lbreeze (snow day)

lect14c-wrap-up
retrospective

What did we talk about this semester, eh?

Web Programming:
  - client-side vs server-side
    (where will "add to database" be?  Where will "de-select checkbox if textbox is empty" be?;
     #transactions made; http header info )
  - php basics: functions, iteration, etc
      Note: php is pass-by-value.  So if I call
          $_POST = tidyArray( $_POST );
      (from hw04/hw04-soln/#validate.php),
      how many times is the array being copied?  four!  (to & from function; once by me manually in loop; once by the '=' !)
         - 4x copying an array of 20 items isn't going to be bad
         - 4x copying large arrays when I'm trying to serve 100pages/sec?  That's more serious! Pass-by-ref.
         - pass-by-ref: but beware; tends to lead to hard-to-track bugs
         - why not just avoid passing altogether, and use $_POST ?
           Many will suggest that, but: 
              if you switch to GET then you'll need to write (and maintain) another copy of htat function;
              if is a general purpose function, you'll *want* it for all arrays.
         - we didn't talk about array_map (and, array_walk), where you pass in a function [or a string -- it's name!]

   - passing state between pages (since http is itself stateless)
       files;  cookies;  sessions;  database

   - XML: hierarchical data (tree) marshaled to text format; human-readable; having a standard is great.
   - XSLT:  a langauge for XML -> XML functions.  
      - it is itself XML
      - processed *client*-side
      - uses xpath expressions (in xsl:foreach, xsl:value-of, xsl:choice etc):
         xpath: expressions evaluate to a *nodeset*.
         absolute vs relative paths -- relative to the node currently being handled (by template, or in loop)
         filter by using [...]

   - web programming: other ways.
     How cool is php?  Nice, low-barrier entry
     But it makes me feel kinda like I'm using assembly-language:
     To make a site about kittens, I need to...
         have a web form, w/ fields for kitten's name, vaccination date, #claws, cuteness level, ...
         do javascript validation on each of those fields
         print out a kitten's info as html
         have php that validates each of those fields
         (maybe: php objects)
         define a database table for kittens
         set up SQL types/constraints for each of those fields
         (maybe also: a java program that interacts with the database: 
              class Kitten { ... } and the constructor with all its validation code for sanity-checking.)
      Oh my goodness, I don't feel so enthused about writing all this code again, in so many different languages
        and in each language remembering how to call 'substring' [method or static?; end-index vs length; neg.indices allowed?] !
        Do we really need a different language for each different stage?
         
      Many before have seen this problem, and sought for a better world.
      - Node.js: These are higher-level functions that do common tasks that we're coming to expect (incl. nice visual effects of I/O)
      - More comprehensive approaches like:  .NET, .asp, rails   --  specify what info a Kitten has just once,
          and let the platform will auto-generate html forms, client-side checking, 
          server-side validation, database def'ns, a java class, etc.
      While XSLT and SQL and Java all have their own strengths,
      I can also choose to use one language, and simply annotate what code is to 
        be performed client-side, and what to be done server-side.
      Yay!

      So the php/javascript in this class grounds you in the 'assembly-level' web programming: 
        you now know/appreciate the low-level work that needs to be done.
      But don't think that just because most sites still use just php/javascript, 
        that it's web programming's highest level!
    

homelectsexamshws
D2Lbreeze (snow day)


©2012, Ian Barland, Radford University
Last modified 2012.Apr.27 (Fri)
Please mail any suggestions
(incl. typos, broken links)
to ibarlandradford.edu
Powered by PLT Scheme