Bài giảng Web Technologies and e-Services - Bài 6: Web development models
3 Tier Layers vs. MVC
•Presentation:
•View is the user interface (e.g. button)
•Controller is the code (e.g. callback for button)
•Data:
•Model is the database
PresentationSummary
§ Client-Server Model
§ 3-Tier Architecture
§ Dynamic Web Programming Languages
§ MVC Model
25 trang |
Chia sẻ: hachi492 | Ngày: 06/01/2022 | Lượt xem: 353 | Lượt tải: 0
Bạn đang xem trước 20 trang tài liệu Bài giảng Web Technologies and e-Services - Bài 6: Web development models, để xem tài liệu hoàn chỉnh bạn click vào nút DOWNLOAD ở trên
Web Development Models
• Web Application Architecture: client-server
• Programming Languages on client side
• Programming Languages on server side
• 3-tier architecture and MVC model
Content
Client-Server Model
Client side Server side
Server Roles
§ Manage and store data, including:
§ User data
§ Application data
§ Provide processing services for data
§ Centralize data
§ Manage user authentication, authorization mechanisms
via login function
Client Roles
§ Provide user interface
§ Can store some small data (using cookie)
§ Can process data (check validity of data that are
entered by users
§ Thin client: only provides user interface, centralize data processing
on server side
§ Thick client: realizes data processing on client side
§ Can be accessed from everywhere with minimal
software installation
Client-Server Advantages
§Centralized storage and processing.
§No data redundancy
§Enhance the ability of sharing data
§ If data are distributed on multi-systems of users, it will cause difficulties in
sharing the data because each system has its own database architecture
3-Tier Architecture
§ Database Tier (Data Access Layer)
§ Stores and accesses data in low-level
§ Server Tier (Business Logic Layer)
§ Manages application connections and process data
§ Client Tier (Presentation Layer)
§ Provides interface and processing
Business
Logic
Layer
Data
Access
Layer
Presentation
Layer
3-Tier Architecture Advantages
§Centralized Database can be accessed by many servers at the
same time
§Allow load balance of user connections on many application servers
§Data Access Layer is consistently designed with hardware in order
to serve specific its tasks:
§Data manipulations: update, insert, remove, etc
§Need more reliable hard drives
§Business Logic Layer are designed to provide connection points
for user connections and run multi-applications
§Need more computing power of CPU
Programming Languages
Client Server Database
Html Java, Ruby SQL
JavaScript Visual Basic NoSQL
Flash PHP, Perl
Python
Client Programming Language
JavaScript
§Event Handling
§Statements (like C / Java)
§Operators
§Variables global (default)
§Or local (e.g. var x = 1)
§Types can change
§Eg. x = 1; x = ‘Hello’
§Function definition (reuse)
§Message Alerts
§Page element access with Document Object Model
§Views HTML page as a tree of elements
Hello World Example
• This provides an annoying popup – try it!
<a href=""
onMouseOver="(alert(
'Follow link to search on Google') )">
Search on Google
Server Programming Language
§Java – uses Java servlets, Java Server Pages (JSP) and Java
Beans.
§Ruby on Rails – uses ruby programs and Embedded Ruby (ERB).
§Visual Basic – Uses VB programs and Active Server Pages (ASP).
§Others:
§PHP (Personal Home Page – originally)
§CGI (Common Gateway Interface)
§Perl (Named after the parable of the pearl)
§Python (Named for the Monty Python skits)
§Tcl (Tool Command Language)
PHP
• Very c-like
• Classes, etc., work very much like C/C++
• Designed to work in the world of HTML
• Is run-time interpreted by the web server
Simple PHP Example
Test page
The time is now
§ PHP is meant to be invoked inline with content Page “escapes” into and out of a regular
html document
§ File extension is .php (was .php3 for version 3)
JSP Example
Hello JSP
Hello World:
Produced
MVC Development Model
§ Architectural Pattern from Smalltalk (1979)
§ Decouples data and presentation
§ Eases the development
MVC – The Model
§ The “Model” contains the data
§ Has methods to access and possibly update it’s contents.
§ Often, it implements an interface which defines the allowed model
interactions.
§ Implementing an interface enables models to be pulled out and
replaced without programming changes.
MVC – The View
§The View provides a visual representation of the model.
§There can be multiple views displaying the model at any one time.
§For example, a companies finances over time could be represented as a
table and a graph.
§These are just two different views of the same data.
§When the model is updated, all Views are informed and given a
chance to update themselves.
MVC – The Controller
§ It interprets mouse movement, clicks, keystrokes, etc
§ Communicates those activities to the model – eg: delete row,
insert row, etc
Example Control Flow in MVC
§ User interacts with the VIEW UI
§ CONTROLLER handles the user input (often a callback function
attached to UI elements)
§ CONTROLLER updates the MODEL
§ VIEW uses MODEL to generate new UI
§ UI waits for user interaction
MVC Advantages
§ MVC decouples the model, view, and controller from
each other to increase flexibility and reuse.
• You can attach multiple views to the model without rewriting it.
• You can change the way a view responds to user input without
changing the visual presentation. For example, you might use
a pop-up menu instead of keyboard command keys.
3 Tier Layers vs. MVC
•Presentation:
• View is the user interface (e.g. button)
• Controller is the code (e.g. callback for button)
•Data:
• Model is the database
Database
Presentation
Summary
§ Client-Server Model
§ 3-Tier Architecture
§ Dynamic Web Programming Languages
§ MVC Model
25
Các file đính kèm theo tài liệu này:
- bai_giang_web_technologies_and_e_services_bai_6_web_developm.pdf