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.

Web Frameworks

510 views

Published on

An introduction to the basic concepts and advantages of web application frameworks.

Published in: Technology
  • Be the first to like this

Web Frameworks

  1. 1. Web Frameworkscode4lib SIG Spring Forum March 16, 2011
  2. 2. SIG Co-convenersJoanna DiPasquale, Columbia University LibrariesKevin Reiss, CUNY Library ServicesYitzchak Schaffer, Touro College Libraries@yitznewton
  3. 3. code4libhttp://code4lib.org/about Grassroots library technology professional... collective Especially interested in the development of open-source software Started in 2003 as email list IRC: #code4lib on chat.freenode.net Annual national conferences (Feb; next year in Seattle) Regional ad hoc meetings (including this SIG) Beer
  4. 4. Why frameworks? DRY - dont repeat yourself within your app among your apps DRE - dont repeat everybody in the greater community Architecture - separation of concerns
  5. 5. DRY / DREChances are your app will require some or all of these: Pretty URLs ( http://mylocalpl.org/news/basement-flooded-again ) Forms and validation Input security Database access → ORM Unit testingSomebody else did that already! Frameworks provide easyways to perform common web tasks.
  6. 6. Separation of concerns Focus on the task at hand - separate out related but different features Easier to decouple and reuse code
  7. 7. <?// posts.php$db = DB::connect( $params );$q = "SELECT * FROM post WHERE title={$_GET[title]}";$result = $db->execute( $q );?><ul> <? while ($row = $db->fetch($result)): ?> <li> <a href="/show.php?id=<? echo $row->id ?>"> <? echo $row->title ?> </a> </li> <? endwhile; ?></ul><? $db->close() ?>
  8. 8. <?include header.inc;$db = DB::connect( $params );$q = "SELECT * FROM post WHERE title={$_GET[title]}";$result = $db->execute( $q );?><ul> <? while ($row = $db->fetch($result)): ?> <li> <a href="/show.php?id=<? echo $row->id ?>"> <? echo $row->title ?> </a> </li> <? endwhile; ?></ul><? $db->close() ?>
  9. 9. // post_controller.php<?$posts = ORM::table(post) ->findByTitle( $params[title] );?>// post_view.php<ul> <? foreach ( $posts as $post ): ?> <li> <? echo link_to( $post->title, post/show?id=.$post->id ) ?> </li> <? endforeach; ?></ul>
  10. 10. Why not frameworks? Server resources overhead (especially RAM) Promote ignorance of low-level processes and attendant issues (SQL injection, cross-site scripting attacks, etc.)

×