CS142 Lecture Notes - FrontEnd
Front End Programming
Mendel Rosenblum
CS142 Lecture Notes - FrontEnd
Brief history of Web Applications
● Initially: static HTML files only with HTML forms for input
● Common Gateway Interface (CGI)
○ Certain URLs map to executable programs that generate web page
○ Program exits after Web page complete
○ Introduced the notion of stateless servers: each request independent, no state
carried over from previous requests. (Made scale-out architectures easier)
○ Perl typically used for writing CGI programs
CS142 Lecture Notes - FrontEnd
First-generation web app frameworks
Examples: (PHP, ASP.net, Java servlets)
● Incorporate language runtime system directly into Web server
● Templates: mix code and HTML - HTML/CSS describes view
● Web-specific library packages:
○ URL handling
○ HTML generation
○ Sessions
○ Interfacing to databases
CS142 Lecture Notes - FrontEnd
Second-generation frameworks
Examples: (Ruby on Rails, Django):
● Model-view-controller: stylized decomposition of applications
● Object-relational mapping (ORM): simplify the use of databases (make
database tables and rows appear as classes and objects)
○ Easier fetching of dynamic data
CS142 Lecture Notes - FrontEnd
Third-generation frameworks
Example: AngularJS
● JavaScript frameworks running in browser - More app-like web apps
○ Interactive, quick responding applications - Don't need server round-trip
● Frameworks not dependent on particular server-side capabilities
○ Node.js - Server side JavaScript
○ No-SQL database (e.g. MongoDB)
● Many of the concepts of previous generations carry forward
○ Model-view-controller
○ Templates - HTML/CSS view description
CS142 Lecture Notes - FrontEnd
Model-View-Controller (MVC) Pattern
● Model: manages the application's data
○ JavaScript objects. Photo App: User names, pictures, comments, etc.
● View: what the web page looks like
○ HTML/CSS. Photo App: View Users, View photo with comments
● Controller: fetch models and control view, handle user interactions
○ JavaScript code. Photo App: DOM event handlers, web server communication
MVC pattern been around since the late 1970's
○ Originally conceived in the Smalltalk project at Xerox PARC
CS142 Lecture Notes - FrontEnd
View Generation
● Web App: Ultimately need to generate HTML and CSS
● Templates are commonly used technique. Basic ideas:
○ Write HTML document containing parts of the page that are always the same.
○ Add bits of code that generate the parts that are computed for each page.
○ The template is expanded by executing code snippets, substituting the results into the
document.
● Benefits of templates (Compare with direct JavaScript to DOM programming)
○ Easy to visualize HTML structure
○ Easy to see how dynamic data fits in
○ Can do either on server or browser
CS142 Lecture Notes - FrontEnd
AngularJS view template (HTML/CSS)
...
<body>
<div class="greetings">
Hello {{models.user.firstName}},
</div>
<div class="photocounts">
You have {{models.photos.count}} photos to review.
</div>
</body>
Angular has rich templating language (loops, conditions, subroutines, etc.). Later...
CS142 Lecture Notes - FrontEnd
Controllers
● Third-generation: JavaScript running in browser
Responsibilities:
● Connect models and views
○ Server communication: Fetch models, push updates
● Control view templates
○ Manage the view templates being shown
● Handle user interactions
○ Buttons, menus, and other interactive widgets
CS142 Lecture Notes - FrontEnd
AngularJS controller (JavaScript function)
function userGreetingView ($scope, $modelService) {
$scope.models = {};
$scope.models.users = $modelService.fetch("users");
$scope.models.photos = $modelService.fetch("photos");
$scope.okPushed = function okPushed() {
// Code for ok button pushing
}
}
Angular creates $scope and calls controller function called when view is
instantiated
CS142 Lecture Notes - FrontEnd
Model Data
● All non-static information needed by the view templates or controllers
● Traditionally tied to application's database schema
○ Object Relational Mapping (ORM) - A model is a table row
● Web application's model data needs are specified by the view designers
But need to be persisted by the database
● Conflict: Database Schemas don't like changing frequently but web
application model data might (e.g. user will like this view better if we add …
and lose ...)
CS142 Lecture Notes - FrontEnd
Angular doesn't specify model data (JavaScript objs)
● Angular provides support for fetching data from a web server
○ REST APIs
○ JSON frequently used
On Server:
● Mongoose's Object Definition Language (ODL) has "models"
var userSchema = new Schema({
firstName: String,
lastName: String,
});
var User = mongoose.model('User', userSchema);
CS142 Lecture Notes - FrontEnd
Fourth-generation frameworks
Examples: React.js, Vue.js, Angular(v2)
● Many of the concepts of previous generations carry forward
○ JavaScript in browser
○ Model-view-controllers
○ Templates
● Focus on JavaScript components rather than pages/HTML
○ Views apps as assembled reusable components rather than pages.
○ Software engineering focus: modular design, reusable components, testability, etc.
● Virtual DOM
○ Render view into DOM-like data structure (not real DOM)
○ Benefits: Performance, Server-side rendering, Native apps

More Related Content

PDF
AngularJS in Production (CTO Forum)
PPTX
Angular jS Introduction by Google
 
PPTX
lecture_32.pptx
PPTX
Lecture 32
DOCX
Understanding Front-End Development: Skills, Tools, and Trends
PPTX
AngularJS Anatomy & Directives
PPT
Intro to-html-backbone
PDF
Web frameworks
AngularJS in Production (CTO Forum)
Angular jS Introduction by Google
 
lecture_32.pptx
Lecture 32
Understanding Front-End Development: Skills, Tools, and Trends
AngularJS Anatomy & Directives
Intro to-html-backbone
Web frameworks

Similar to FrontEnd.pdf (20)

PDF
The State of Front-end At CrowdTwist
PDF
Javascript Client & Server Architectures
PDF
Server Side Javascript
PDF
AngularJS - A Powerful Framework For Web Applications
PDF
The Frontend Developer Landscape Explained and the Rise of Advanced Frontend ...
PDF
Angular js gtg-27feb2013
PDF
All You Need to Know About Front End.pdf
PPTX
Planbox Backbone MVC
PDF
(Ebook) Practical Web Development by kan
PDF
Frontend Developer Roadmap PDF By Scholarhat
PDF
Front end architecture patterns
PPTX
The Best Web Development Services And Company in Usa
PDF
Structured web apps
PPTX
Front End Development | Introduction
PDF
Angular JS Basics
PDF
Introduction to javascript technologies
PDF
C# Advanced L09-HTML5+ASP
PDF
Intro to-html-backbone-angular
PDF
"A Highly Decoupled Front-end Framework for High Trafficked Web Applications"...
PDF
Kann JavaScript elegant sein?
The State of Front-end At CrowdTwist
Javascript Client & Server Architectures
Server Side Javascript
AngularJS - A Powerful Framework For Web Applications
The Frontend Developer Landscape Explained and the Rise of Advanced Frontend ...
Angular js gtg-27feb2013
All You Need to Know About Front End.pdf
Planbox Backbone MVC
(Ebook) Practical Web Development by kan
Frontend Developer Roadmap PDF By Scholarhat
Front end architecture patterns
The Best Web Development Services And Company in Usa
Structured web apps
Front End Development | Introduction
Angular JS Basics
Introduction to javascript technologies
C# Advanced L09-HTML5+ASP
Intro to-html-backbone-angular
"A Highly Decoupled Front-end Framework for High Trafficked Web Applications"...
Kann JavaScript elegant sein?
Ad

More from stephanedjeukam1 (11)

PDF
PDF
Database.pdf
PDF
PDF
CodeInjection.pdf
PDF
Express.pdf
PDF
Input.pdf
PDF
PDF
PDF
DOSAttacks.pdf
PDF
0000 Syllabus.pdf
PDF
Events.pdf
Database.pdf
CodeInjection.pdf
Express.pdf
Input.pdf
DOSAttacks.pdf
0000 Syllabus.pdf
Events.pdf
Ad

Recently uploaded (20)

PPTX
Cyber Hygine IN organizations in MSME or
PDF
SlidesGDGoCxRAIS about Google Dialogflow and NotebookLM.pdf
PDF
Virtual Guard Technology Provider_ Remote Security Service Solutions.pdf
PPTX
COPD_Management_Exacerbation_Detailed_Placeholders.pptx
PDF
BIOCHEM CH2 OVERVIEW OF MICROBIOLOGY.pdf
PPSX
AI AppSec Threats and Defenses 20250822.ppsx
PPTX
The-Importance-of-School-Sanitation.pptx
PPTX
ECO SAFE AI - SUSTAINABLE SAFE AND HOME HUB
PPTX
IPCNA VIRTUAL CLASSES INTERMEDIATE 6 PROJECT.pptx
PDF
The Evolution of Traditional to New Media .pdf
PDF
Exploring The Internet Of Things(IOT).ppt
PPT
12 Things That Make People Trust a Website Instantly
PPTX
MY PRESENTATION66666666666666666666.pptx
DOCX
Powerful Ways AIRCONNECT INFOSYSTEMS Pvt Ltd Enhances IT Infrastructure in In...
PDF
simpleintnettestmetiaerl for the simple testint
PDF
mera desh ae watn.(a source of motivation and patriotism to the youth of the ...
PDF
Buy Cash App Verified Accounts Instantly – Secure Crypto Deal.pdf
PPTX
Reading as a good Form of Recreation
PDF
Session 1 (Week 1)fghjmgfdsfgthyjkhfdsadfghjkhgfdsa
PPTX
Artificial_Intelligence_Basics use in our daily life
Cyber Hygine IN organizations in MSME or
SlidesGDGoCxRAIS about Google Dialogflow and NotebookLM.pdf
Virtual Guard Technology Provider_ Remote Security Service Solutions.pdf
COPD_Management_Exacerbation_Detailed_Placeholders.pptx
BIOCHEM CH2 OVERVIEW OF MICROBIOLOGY.pdf
AI AppSec Threats and Defenses 20250822.ppsx
The-Importance-of-School-Sanitation.pptx
ECO SAFE AI - SUSTAINABLE SAFE AND HOME HUB
IPCNA VIRTUAL CLASSES INTERMEDIATE 6 PROJECT.pptx
The Evolution of Traditional to New Media .pdf
Exploring The Internet Of Things(IOT).ppt
12 Things That Make People Trust a Website Instantly
MY PRESENTATION66666666666666666666.pptx
Powerful Ways AIRCONNECT INFOSYSTEMS Pvt Ltd Enhances IT Infrastructure in In...
simpleintnettestmetiaerl for the simple testint
mera desh ae watn.(a source of motivation and patriotism to the youth of the ...
Buy Cash App Verified Accounts Instantly – Secure Crypto Deal.pdf
Reading as a good Form of Recreation
Session 1 (Week 1)fghjmgfdsfgthyjkhfdsadfghjkhgfdsa
Artificial_Intelligence_Basics use in our daily life

FrontEnd.pdf

  • 1. CS142 Lecture Notes - FrontEnd Front End Programming Mendel Rosenblum
  • 2. CS142 Lecture Notes - FrontEnd Brief history of Web Applications ● Initially: static HTML files only with HTML forms for input ● Common Gateway Interface (CGI) ○ Certain URLs map to executable programs that generate web page ○ Program exits after Web page complete ○ Introduced the notion of stateless servers: each request independent, no state carried over from previous requests. (Made scale-out architectures easier) ○ Perl typically used for writing CGI programs
  • 3. CS142 Lecture Notes - FrontEnd First-generation web app frameworks Examples: (PHP, ASP.net, Java servlets) ● Incorporate language runtime system directly into Web server ● Templates: mix code and HTML - HTML/CSS describes view ● Web-specific library packages: ○ URL handling ○ HTML generation ○ Sessions ○ Interfacing to databases
  • 4. CS142 Lecture Notes - FrontEnd Second-generation frameworks Examples: (Ruby on Rails, Django): ● Model-view-controller: stylized decomposition of applications ● Object-relational mapping (ORM): simplify the use of databases (make database tables and rows appear as classes and objects) ○ Easier fetching of dynamic data
  • 5. CS142 Lecture Notes - FrontEnd Third-generation frameworks Example: AngularJS ● JavaScript frameworks running in browser - More app-like web apps ○ Interactive, quick responding applications - Don't need server round-trip ● Frameworks not dependent on particular server-side capabilities ○ Node.js - Server side JavaScript ○ No-SQL database (e.g. MongoDB) ● Many of the concepts of previous generations carry forward ○ Model-view-controller ○ Templates - HTML/CSS view description
  • 6. CS142 Lecture Notes - FrontEnd Model-View-Controller (MVC) Pattern ● Model: manages the application's data ○ JavaScript objects. Photo App: User names, pictures, comments, etc. ● View: what the web page looks like ○ HTML/CSS. Photo App: View Users, View photo with comments ● Controller: fetch models and control view, handle user interactions ○ JavaScript code. Photo App: DOM event handlers, web server communication MVC pattern been around since the late 1970's ○ Originally conceived in the Smalltalk project at Xerox PARC
  • 7. CS142 Lecture Notes - FrontEnd View Generation ● Web App: Ultimately need to generate HTML and CSS ● Templates are commonly used technique. Basic ideas: ○ Write HTML document containing parts of the page that are always the same. ○ Add bits of code that generate the parts that are computed for each page. ○ The template is expanded by executing code snippets, substituting the results into the document. ● Benefits of templates (Compare with direct JavaScript to DOM programming) ○ Easy to visualize HTML structure ○ Easy to see how dynamic data fits in ○ Can do either on server or browser
  • 8. CS142 Lecture Notes - FrontEnd AngularJS view template (HTML/CSS) ... <body> <div class="greetings"> Hello {{models.user.firstName}}, </div> <div class="photocounts"> You have {{models.photos.count}} photos to review. </div> </body> Angular has rich templating language (loops, conditions, subroutines, etc.). Later...
  • 9. CS142 Lecture Notes - FrontEnd Controllers ● Third-generation: JavaScript running in browser Responsibilities: ● Connect models and views ○ Server communication: Fetch models, push updates ● Control view templates ○ Manage the view templates being shown ● Handle user interactions ○ Buttons, menus, and other interactive widgets
  • 10. CS142 Lecture Notes - FrontEnd AngularJS controller (JavaScript function) function userGreetingView ($scope, $modelService) { $scope.models = {}; $scope.models.users = $modelService.fetch("users"); $scope.models.photos = $modelService.fetch("photos"); $scope.okPushed = function okPushed() { // Code for ok button pushing } } Angular creates $scope and calls controller function called when view is instantiated
  • 11. CS142 Lecture Notes - FrontEnd Model Data ● All non-static information needed by the view templates or controllers ● Traditionally tied to application's database schema ○ Object Relational Mapping (ORM) - A model is a table row ● Web application's model data needs are specified by the view designers But need to be persisted by the database ● Conflict: Database Schemas don't like changing frequently but web application model data might (e.g. user will like this view better if we add … and lose ...)
  • 12. CS142 Lecture Notes - FrontEnd Angular doesn't specify model data (JavaScript objs) ● Angular provides support for fetching data from a web server ○ REST APIs ○ JSON frequently used On Server: ● Mongoose's Object Definition Language (ODL) has "models" var userSchema = new Schema({ firstName: String, lastName: String, }); var User = mongoose.model('User', userSchema);
  • 13. CS142 Lecture Notes - FrontEnd Fourth-generation frameworks Examples: React.js, Vue.js, Angular(v2) ● Many of the concepts of previous generations carry forward ○ JavaScript in browser ○ Model-view-controllers ○ Templates ● Focus on JavaScript components rather than pages/HTML ○ Views apps as assembled reusable components rather than pages. ○ Software engineering focus: modular design, reusable components, testability, etc. ● Virtual DOM ○ Render view into DOM-like data structure (not real DOM) ○ Benefits: Performance, Server-side rendering, Native apps