Document not found! Please try again

Web Application Frameworks

6 downloads 365 Views 2MB Size Report
Jay Urbain, Ph.D. ... development of dynamic websites, web applications, web ... Mojolicious, Ruby on Rails, Django, Zend Framework, Yii, CakePHP and.
Web  Applica+on  Frameworks  

  Jay  Urbain,  Ph.D.   Credits:     www   h6p://en.wikipedia.org/   Ma5  Raible:  h6p://raibledesigns.com   h6p://www.techempower.com/benchmarks        

1

2

Frameworks   •  An  applica+on  framework  consists  of  a  so9ware  framework   used  to  implement  the  standard  structure  (architecture)  of   an  applicaEon.   •  The  so9ware  framework  providing  generic  funcEonality  can   be  selecEvely  changed  to    provide  applica&on-­‐specific   soHware.    

3

ApplicaEon  Frameworks   •  ApplicaEon  frameworks  became  popular  with  the  rise   of  graphical  user  interfaces  (GUIs),  since  these  tended  to   promote  a  standard  structure  for  applicaEons.     •  Simpler  to  create  automaEc  GUI  creaEon  tools  when  using  a   standard  framework,  since  this  defines  the  underlying  code   structure  of  the  applicaEon  in  advance.   •  Apple  Computer  developed  one  of  the  first  commercial   applicaEon  frameworks,  MacApp  (first  released  in  1985),  for   the  Macintosh.    

4

Many  ApplicaEon  Frameworks…   •  Cocoa  for  Mac  OS  X  is  an  applicaEon  framework  based  upon   the  OPENSTEP  framework  developed  at  NeXT.   •  Free-­‐soHware  frameworks  exist  as  part  of  the  Mozilla,  OpenOffice.org,   GNOME,  KDE,  NetBeans,  and  Eclipse  projects.   •  MicrosoH  markets  a  number  of  framework  for  developing  Windows   applicaEons.   •  A  number  of  frameworks  can  build  cross-­‐pla0orm  applicaEons  for  Linux,   Macintosh,  and  Windows  from  the  same  source  code:  Qt,  the  widget   toolkits  wxWidgets,  FOX  toolkit,  or  Eclipse  RCP.   •  Oracle  ApplicaEon  Development  Framework  (Oracle  ADF)  aids  in   producing  Java-­‐oriented  systems.   •  Nega&ves?   5

Web  ApplicaEon  Framework  (WAF)   •  WAF  is  a  soHware  framework  designed  to  support  the   development  of  dynamic  websites,  web  applicaEons,  web   services,  and  web  resources.     •  Aims  to  alleviate  the  overhead  associated  with  common   acEviEes  performed  in  web  development.     •  Many  frameworks  provide  libraries  for  database  access,   templaEng,  and  session  management.   •  OHen  promote  code  reuse.    

6

A  li6le  Web  history…   •  World  Wide  Web  was  not  inherently  dynamic.  Early  hypertext  consisted  of   hand-­‐coded  HTML  that  was  published  on  web  servers.       –  Any  modificaEons  to  published  pages  needed  to  be  performed  by  the   pages'  author.     •  To  provide  a  dynamic  web  page  that  reflected  user  inputs,  the  Common   Gateway  Interface  (CGI)  standard  was  introduced  for  interfacing  external   applicaEons  with  web  servers.   –  CGI  could  adversely  affect  server  load,  though,  since  each  request  had   to  start  a  separate  process.  

7

…  a  li6le  more  Web  history…   •  Programmers  wanted  Eghter  integraEon  with  the  web  server  to  enable   high  traffic  web  applicaEons.     –  The  Apache  HTTP  Server  supports  modules  that  can  extend  the  web   server  with  arbitrary  code  execuEons  (e.g.,  as  Mod  Perl).   –  Some  web  servers  (e.g.,  Apache  Tomcat)  were  specifically  designed  to   handle  dynamic  content  by  execuEng  code  wri6en  in  some  languages   (e.g.,  Java).   –  Around  the  same  Eme,  new  languages  were  being  developed   specifically  for  use  on  the  web  such  as  ColdFusion,  PHP  and  AcEve   Server  Pages.  

8

…  the  end  of  history.   •  Majority  of  languages  available  for  creaEng  dynamic  web  pages   have  libraries  to  help  with  common  tasks.   •  Eventually  more  mature,  "full  stack"  frameworks  appeared  that   aggregated  libraries  and  provide  a  structure  (architectural  approach)   useful  for  web  development.     •  Examples:     –  ASP.NET,  Java  EE  (Servlets),  WebObjects,  web2py,  OpenACS,  Catalyst,   Mojolicious,  Ruby  on  Rails,  Django,  Zend  Framework,  Yii,  CakePHP  and   Symfony,  etc.  

9

Types  of  framework  architectures   Model–view–controller  (MVC)     •  Many  frameworks  follow  the  MVC  architectural  pa6ern  to  separate   the  data  model  with  business  rules  from  the  user  interface.     •  Considered  a  good  pracEce  as  it  modularizes  code,  promotes  code  reuse,   and  allows  mulEple  interfaces  to  be  applied.     •  In  web  applicaEons,  this  permits  different  views  to  be  presented,  such   as  web  pages  for  humans,  and  web  service  interfaces  for  mobile  and  other   remote  applicaEons.  

10

Push-­‐based  vs.  pull-­‐based   architectures     Push-­‐based   •  Most  MVC  frameworks  follow  a  push-­‐based  architecture  also  called  "ac&on-­‐ based."     •  These  frameworks  use  ac&ons  (commands)  that  do  the  required  processing,   and  then  "push"  the  data  to  the  view  layer  to  render  the  results.   •  This  is  the  approach  we  have  followed  in  class  with  our  MVC   implementa&on.   •  Examples:    EStruts,  Django,  Ruby  on  Rails,  Symfony,  Yii,  Spring  MVC,  Stripes,   Play,  CodeIgniter,  and  Struts2.  

11

Push-­‐based  vs.  pull-­‐based   architectures     Pull-­‐based   •  An  alternaEve  to  a  push-­‐based  architecture,  is  a  pull-­‐based  architecture.   SomeEmes  called  "component-­‐based."   •  These  frameworks  start  with  the  view  layer,  which  can  then  "pull"  results   from  mulEple  controllers/sources  as  needed.  In  this  architecture,  mulEple   controllers  can  be  involved  with  a  single  view.     •  Typically,  more  “page”  centric.   •  Examples:  LiH,  Tapestry,  JBoss  Seam,  JavaServer  Faces,  and  Wicket.  

12

Three-­‐Eer  architectures   •  Three  Eer  applicaEons  are  structured  around  three  logical   Eers:  presentaEon  (client),  business  logic  (applicaEon),  and   data  (database).     Three  Eer  is  a  different,  but  complimentary  abstracEon  from   MVC.   •  View   –  PresentaEon  can  be  generated  server-­‐  or  client  slide.  

•  Model   –  Business  logic   –  Data  

•  Controller   –  Client  interacEon,  separates  Model  from  View  

13

WAF  Features   •  Web  template  system   –  Code  that  generates  the  HTML  can  do  this  based  on  variables  in  a   template,  or  on  code.  

•  Caching   –  Reduce  bandwidth,  server  load,  and  latency.     –  A  web  cache  stores  copies  of  documents  passing  through  it.     –  Subsequent  requests  may  be  saEsfied  from  the  cache  if  certain   condiEons  are  met.    

•  Security   –   AuthenEcaEon  and  authorizaEon  frameworks  that  enable  the  web   server  to  idenEfy  the  users  of  the  applicaEon,  and  restrict  access  to   funcEons  based  on  some  defined  criteria  respecEvely.  

14

WAF  Features  -­‐  2   •  Database  access,  mapping  and  configura+on   –  Unified  API  to  a  database  backend,  enabling  web  applicaEons  to  work   with  a  variety  of  databases.   –  Object  to  relaEonal  mapping.  

•  Scaffolding   –  Generate  code  from  specificaEon,  e.g.,  XML.  

•  URL  mapping   –  Mechanism  by  which  the  framework  interprets  URLs.    

15

WAF  Features  -­‐  3   •  Ajax   –  Due  to  the  complexity  of  Ajax  programming  in  JavaScript,  there  are   numerous  Ajax  frameworks  that  exclusively  deal  with  Ajax  support.     –  Some  Ajax  frameworks  are  embedded  as  a  part  of  larger  frameworks.   E.g.,    jQuery  JavaScript  library  is  included  in  Ruby  on  Rails.   –  Compiler  technology  has  been  developed  to  allow  developers  to  code   in  high-­‐level  languages  such  as  Java,  Python  and  Ruby.     –  One  of  the  first  of  these  compilers  was  Morfik,  followed  by  Google   Web  Toolkit,  with  ports  to  Python  and  Ruby  in  the  form  of  Pyjamas   and  RubyJS  following  some  Eme  aHer.    

16

WAF  Features  -­‐  4   •  Web  services     –  Provide  tools  for  creaEng  and  providing  web  services.     –  These  uEliEes  may  offer  similar  tools  as  the  rest  of  the  web   applicaEon.  

•  Web  resources     –  A  number  of  newer  Web  2.0  RESTful  frameworks  are  now  providing   resource-­‐oriented  architecture  (ROA)  infrastructure  for  building   collecEons  of  resources  in  a  SemanEc  Web  ontology,  based  on   concepts  from  Resource  DescripEon  Framework  (RDF).  

17

History  of  Web  Frameworks  

18

History  of  Web  Frameworks  -­‐  2  

19

History  of  Web  Frameworks  -­‐  3  

20

History  of  Web  Frameworks  -­‐  4  

21

History  of  Web  Frameworks  -­‐5  

22

History  of  Web  Frameworks  -­‐  6  

23

Today  

24

Too  many  frameworks?  

25

How  to  select  a  Web  ApplicaEon   Framework?   •  •  • 

•  •  • 

• 

Maturity  and  Popularity   –  How  long  the  framework  has  been  around  and  how  likely  it  is  to  evolve  are  key   consideraEons  when  comparing  web  frameworks.     AJAX   –  AJAX  is  complex  technology.   LocalizaEon     –  The  ability  to  adapt  to  mulEple  languages  is  a  common  component  of  most  frameworks.    

Security  and  Form  ValidaEon  

–  DeclaraEve  authorizaEon  and  authenEcaEon,  form  validaEon.   CustomizaEon  and  Extensibility   –  Templates,  theme  availability  or  support  for  CSS  are  a  must  if  the  user  experience  and   overall  design  of  your  website  are  important.     MVC  Structure  and  ORM   –  The  Model-­‐View-­‐Controller  (MVC)  determines  how  the  end-­‐user  interacts  with  the   framework,  how  event  calls  are  handled  and  if  it  supports  dynamics  such  as  updaEng  a   post  or  shopping  cart.     –  Object-­‐relaEonal  Mapping  (ORM)  support  enables  you  to  update  the  API  or  key   components  of  your  site  without  impacEng  the  front-­‐end.   Scalability   26

How  to  select  a  Web  ApplicaEon   Framework  –  Standard  Java  EE   •  •  • 

•  •  • 

• 

Maturity  and  Popularity  -­‐  YES   –  How  long  the  framework  has  been  around  and  how  likely  it  is  to  evolve  are  key   consideraEons  when  comparing  web  frameworks.     AJAX-­‐  No  (use  JQuery)   –  AJAX  is  complex  technology.   LocalizaEon-­‐  YES     –  The  ability  to  adapt  to  mulEple  languages  is  a  common  component  of  most  frameworks.    

Security  and  Form  ValidaEon-­‐  YES  for  security,  use  JQuery  for  client,  need  to  provide   server-­‐side  validaEon.  

–  DeclaraEve  authorizaEon  and  authenEcaEon,  form  validaEon.   CustomizaEon  and  Extensibility-­‐  YES  for  templates,  NO  for  CSS   –  Templates,  theme  availability  or  support  for  CSS  are  a  must  if  the  user  experience  and   overall  design  of  your  website  are  important.     MVC  Structure  and  ORM-­‐  You  have  MVC  from  class!,  consider  Hibernate  or  applicaEon  specific   ORM.   –  The  Model-­‐View-­‐Controller  (MVC)  determines  how  the  end-­‐user  interacts  with  the   framework,  how  event  calls  are  handled  and  if  it  supports  dynamics  such  as  updaEng  a   post  or  shopping  cart.     –  Object-­‐relaEonal  Mapping  (ORM)  support  enables  you  to  update  the  API  or  key   components  of  your  site  without  impacEng  the  front-­‐end.   Scalability-­‐  Can  be  highly  scalable.   27

A  more  discriminaEve  choice  criteria   •  •  •  •  •  • 

Community  /  Support   HTML5   ReST   Mobile   Performance   Page  Speed  

28

Predetermined  Constraints   •  Language   •  Plauorm   •  ApplicaEon  Type  

29

If  you  choose  JVM  

30

Pure  JVM  Frameworks   •  •  •  •  • 

Apache:  Wicket,  Struts,  Sling,  Tapestry,  Click   GWT:  SmartGWT,  GXT,  Vaadin,  Errai   JSF:  Mojarra  (RI),  MyFaces,  Tomahawk,  IceFaces,  RichFaces,   PrimeFaces   Spring  MVC,  Stripes,  RIFE,  ZK,  Gemini  

h6p://en.wikipedia.org/wiki/ Comparison_of_web_applicaEon_frameworks#Java    

31

Ma6  Raiblem,  DEVOXX  Overall  Score  

32

Ma6  Raiblem,  DEVOXX  Overall  Score  

33

Ma6  Raiblem,  DEVOXX  Overall  Score   Weighted  Results   •  Grails  (90)   •  Play  (87.5)   •  Spring  MVC  (85)   •  Ruby  on  Rails  (82.5)   •  Vaadin  (82.5)   •  GWT  (80)  

34

Framework  Performance   •  • 

• 

•  • 

Its  no  secret  that  the  performance  of  web  applica&ons  is  highly  dependent  on  the   chosen  framework.   But  many  are  surprised  at  how  much  of  a  difference.  If  you’re  using  Django,  Ruby  on   Rails  and  similar  frameworks,  the  applicaEon  will  be  about  40  &mes  slower  than   selecEng  a  faster  framework.  And  if  you  choose  Cake  PHP,  the  difference  increases  by   an  order  of  magnitude.   The  company  TechEmpower  conducted  comparaEve  tesEng  of  frameworks,  micro-­‐ frameworks  and  plauorms  for  web  development,  configuring  their  best,  but  without   the  use  of  caching,  placing  the  applicaEon  on  Amazon  EC2  (Core  i7,  Ubuntu  12.04)   and  run  a  program  for  stress  tests  WeigHTTP.  Then  repeated  the  tests  on  a  dedicated   server.   The  enEre  tesEng  procedure  describing  the  configuraEon  of  each  framework   published  on  Github.     The  tests:   -­‐  SerializaEon  JSON;   -­‐  SerializaEon  JSON  on  a  dedicated  server;   -­‐  Access  to  the  database  (RPS);   -­‐  Access  to  the  database  on  a  dedicated  server;   -­‐  Access  to  the  database,  the  query  1-­‐20;   -­‐  Access  to  the  database,  at  1-­‐20  queries  on  a  dedicated  server;   -­‐  For  example,  here  are  the  results  for  JSON  serializaEon  in  an  instance  on  EC2.  

35

Framework  Performance  

36

37

Ruby  on  Rails   •  Open  source  web  applicaEon  framework  which  runs  on  the  Ruby   programming  language.     –  Ruby  is  a  general-­‐purpose  object-­‐oriented  programming  dynamic   (scripEng)  language  that  combines  syntax  inspired  by  Perl  with   Smalltalk-­‐like  features.       –  A  scripEng  language  that  is  considered  more  powerful  than  Perl,  and   more  object-­‐oriented  than  Python.     •  Full-­‐stack  framework:     –  Allows  creaEng  pages  and  applicaEons  that  gather  informaEon  from   the  web  server,  talk  to  or  query  the  database,  and  render  templates   out  of  the  box.     –  As  a  result,  Rails  features  a  rouEng  system  that  is  independent  of  the   web  server.   •  Emphasizes  use  of  well-­‐known  pa6erns  and  principles:  acEve  record   pa6ern,  convenEon  over  configuraEon,  don't  repeat  yourself,  and  model-­‐ view-­‐controller.   38

Ruby  on  Rails  -­‐  2   •  Uses  the  Model-­‐View-­‐Controller  (MVC)  architecture  pa6ern.   •  Model  maps  to  a  table  in  a  database  (acEve  record  pa6ern),  and  a  Ruby  file.     –  Example:  a  model  class  User  will  usually  be  defined  in  the  file  user.rb  in  the  app/models   directory,  and  is  linked  to  the  table  users  in  the  database.    

•  Controller  responds  to  external  requests  from  the  web  server  to  the   applicaEon  by  determining  which  view  file  to  render.     –  Controller  may  also  have  to  query  one  or  more  models  directly  for  informaEon  and  pass   these  on  to  the  view.     –  Controller  may  provide  one  or  more  acEons.  An  acEon  is  a  basic  unit  that  describes  how  to   respond  to  a  specific  external  web-­‐browser  request.    

•  A  view  (default  configuraEon)  is  an  erb  file,  which  is  converted  to  HTML  at   run-­‐Eme  (template  pa6ern).   •  Includes  tools  that  make  common  development  tasks  easier  "out  of  the   box",  such  as  scaffolding  that  can  automaEcally  construct  some  of  the   models  and  views  needed  for  a  basic  website.   39

Spring  Framework   •  The  core  features  can  be  used  by  any  Java  applicaEon.   •  Extensions  for  building  web  applicaEons  on  top  of  the  Java  EE  plauorm.     •  Does  not  impose  any  specific  programming  model,  but  it  has  become   popular  in  the  Java  community  as  an  alternaEve  to,  replacement  for,  or   even  addiEon  to  the  Enterprise  JavaBean  (EJB)  model.  

40

Spring  Framework  comprises  several   modules  that  provide  services:   •  Inversion  of  control  container:  configuraEon  of  applicaEon  components   and  via  dependency  injecEon  (object  coupling  is  bound  at  run  Eme  –  think   Observer).   •  Aspect-­‐oriented  programming:  enables  implemenEng  cross-­‐cu{ng   concerns.   •  Data  access:  database  management  systems  on  the  Java  plauorm  using   JDBC  and  object-­‐relaEonal  mapping  tools  and  with  NoSQL  databases   •  TransacEon  management:  unifies  several  transacEon  management  APIs   and  coordinates  transacEons  for  Java  objects   •  Model–view–controller:  an  HTTP-­‐  and  servlet-­‐based  framework  providing   hooks  for  extension  and  customizaEon  for  web  applicaEons  and  RESTful   web  services.  

41

Spring  Framework  comprises  several   modules  that  provide  services  cont.:   •  Remote  access  framework:  RPC-­‐style  marshaling  of  Java  objects  over   networks  supporEng  RMI,  CORBA  and  HTTP-­‐based  protocols  including   web  services  (SOAP)   •  ConvenEon  over  configuraEon:  rapid  applicaEon  development  (seeks  to   decrease  the  number  of  decisions  that  developers  need  to  make)  for   simplicity.   •  AuthenEcaEon  and  authorizaEon:  configurable  security  processes.   •  Remote  management:  configuraEve  exposure  and  management  of  Java   objects  for  local  or  remote  configuraEon  via  JMX   •  Messaging:  configuraEve  registraEon  of  message  listener  objects  for   transparent  message-­‐consumpEon  from  message  queues  via  JMS,   improvement  of  message  sending  over  standard  JMS  APIs   •  TesEng:  support  classes  for  wriEng  unit  tests  and  integraEon  tests   42

Python  Django   Django   •  Open  source  web  applicaEon  framework  which  follows  the  MVC  pa6ern.   •  Primary  goal  is  to  ease  the  creaEon  of  complex,  database-­‐driven  websites.     •  Emphasizes  reusability  and  "pluggability"  of  components,  rapid   development,  and  the  principle  of  don't  repeat  yourself.     •  Python  is  used  throughout,  even  for  se{ngs,  files,  and  data  models.     •  Django  also  provides  an  opEonal  administraEve  create,  read,  update  and   delete  interface  that  is  generated  dynamically  through  introspecEon  and   configured  via  admin  models.   Many  others   •  Grok,  Pylons,  TurboGears,  web2py,  Zope2  

43

Grails   •  Grails  is  an  open  source  web  applicaEon  framework  which   uses  the  Groovy  programming  language  (which  is  in  turn   based  on  the  Java  plauorm  –  runs  on  JVM).     •  Intended  to  be  a  high-­‐producEvity  framework  by  following   the  "coding  by  convenEon"  paradigm,  providing  a  stand-­‐alone   development  environment  and  hiding  much  of  the   configuraEon  detail  from  the  developer.   •  Use  to  be  called  Groovy  on  Rails.   •  h6p://www.grails.org/  

44

JavaServer  Faces   •  Java  specificaEon  and  framework  for  building  component-­‐based   user  interfaces  for  web  applicaEons.   •  Component-­‐driven  UI  design  model,  using  XML  files  called  view   templates  or  Facelets  views.     •  Requests  are  processed  by  the  FacesServlet,  which  loads  the   appropriate  view  template,  builds  a  component  tree,  processes   events,  and  renders  the  response,  typically  in  the  HTML  language,   to  the  client.     •  Built-­‐in  support  for  Ajax  (RIA).   •  The  state  of  UI  components  and  other  objects  of  scope  interest,  is   saved  at  the  end  of  each  request  in  a  process  called   stateSaving  and  restored  upon  next  creaEon  of  that  view.     •  Objects  and  states  can  be  saved  either  on  the  client  or  server  side.   45

ASP.NET   •  Server-­‐side  Web  applicaEon  framework  designed  for  Web  development  to   produce  dynamic  Web  pages,  applicaEons  and  services..     •  Developed  and  supported  by  MicrosoH  to  allow  programmers  to  build   dynamic  web  sites,  web  applicaEons  and  web  services.     •  Successor  to  MicrosoH's  AcEve  Server  Pages  (ASP).     •  ASP.NET  is  built  on  the  Common  Language  RunEme  (CLR),  allowing   programmers  to  write  ASP.NET  code  using  any  supported  .NET  language   •  ASP.NET  Web  pages,  known  officially  as  Web  Forms,  are  the  main  building   blocks  for  applicaEon  development.  

46

PHP   •  Server-­‐side  scripEng  language  designed  for  web   development,  but  also  used  as  a  general-­‐purpose   programming  language.     •  PHP  is  now  installed  on  more  than  244  million  websites  and   2.1  million  web  servers.   •  PHP  code  is  interpreted  by  a  web  server  with  a  PHP  processor   module  which  generates  the  resulEng  web  page.   •  PHP  commands  can  be  embedded  directly  into  an  HTML   source  document  rather  than  calling  an  external  file  to   process  data.     •  PHP  is  free  open-­‐source  soHware.   47

Suggest Documents