Web Applications Best Practices

Slides:



Advertisements
Similar presentations
PHP SQL. Connection code:- mysql_connect("server", "username", "password"); Connect to the Database Server with the authorised user and password. Eg $connect.
Advertisements

Apache Struts Technology
INTRODUCTION TO ASP.NET MVC AND EXAMPLE WALKTHROUGH RAJAT ARYA EFECS - OIM DAWG – 4/21/2009 ASP.NET MVC.
1.  Understanding about How to Working with Server Side Scripting using PHP Framework (CodeIgniter) 2.
Objective Understand web-based digital media production methods, software, and hardware. Course Weight : 10%
Fast Track to ColdFusion 9. Getting Started with ColdFusion Understanding Dynamic Web Pages ColdFusion Benchmark Introducing the ColdFusion Language Introducing.
Lecture 4: Introduction to PHP 3 PHP & MySQL
The course builder architecture & project planning presented by: Bahareh Agha Jafari.
Web Application Architecture: multi-tier (2-tier, 3-tier) & mvc
UNIT-V The MVC architecture and Struts Framework.
Martin Kruliš by Martin Kruliš (v1.0)1.
22-Aug-15 | 1 |1 | Help! I need more servers! What do I do? Scaling a PHP application.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
CodeIgniter - [Overview]
Database Design for DNN Developers Sebastian Leupold.
NOTE: To change the image on this slide, select the picture and delete it. Then click the Pictures icon in the placeholder to insert your own image. WEB.
What is Architecture  Architecture is a subjective thing, a shared understanding of a system’s design by the expert developers on a project  In the.
Todd Snyder Development Team Lead Infragistics Experience Design Group.
Fall CIS 764 Database Systems Design L8. Web ….
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
Symfony web development framework is used to develop rapid, complex and large scale web applications faster and in an effective way.
Webcommerce Computer Networks Webcommerce by Linnea Reppa Douglas Martindale Lev Shalevich.
WEB BASED DATA TRANSFORMATION USING XML, JAVA Group members: Darius Balarashti & Matt Smith.
Introduction to Web Dimitar Nenchev Ivan Nakov
Prof Frankl, Spring 2008CS Polytechnic University 1 Overview of Web database applications with PHP.
1 Geospatial and Business Intelligence Jean-Sébastien Turcotte Executive VP San Francisco - April 2007 Streamlining web mapping applications.
Architectural Patterns Support Lecture. Software Architecture l Architecture is OVERLOADED System architecture Application architecture l Architecture.
How does Drupal Work? Information Systems 337 Prof. Harry Plantinga.
Model View Controller MVC Web Software Architecture.
ASP (Active Server Pages) by Bülent & Resul. Presentation Outline Introduction What is an ASP file? How does ASP work? What can ASP do? Differences Between.
 Registry itself is easy and straightforward in implementation  The objects of registry are actually complicated to store and manage  Objects of Registry.
SimDB Implementation & Browser IVOA InterOp 2008 Meeting, Theory Session 1. Baltimore, 26/10/2008 Laurent Bourgès This work makes use of EURO-VO software,
Martin Kruliš by Martin Kruliš (v1.1)1.
Plug-in Architectures Presented by Truc Nguyen. What’s a plug-in? “a type of program that tightly integrates with a larger application to add a special.
MVC WITH CODEIGNITER Presented By Bhanu Priya.
Martin Kruliš by Martin Kruliš (v1.1)1.
Fundamentals of Web DevelopmentRandy Connolly and Ricardo HoarFundamentals of Web DevelopmentRandy Connolly and Ricardo Hoar Fundamentals of Web DevelopmentRandy.
Understanding Web-Based Digital Media Production Methods, Software, and Hardware Objective
Testing Your Alfresco Add-ons Michael Suzuki Software Engineer.
START Application Spencer Johnson Jonathan Barella Cohner Marker.
Dynamic SQL Writing Efficient Queries on the Fly ED POLLACK AUTOTASK CORPORATION DATABASE OPTIMIZATION ENGINEER.
CS520 Web Programming Spring – Web MVC Chengyu Sun California State University, Los Angeles.
Web Technology Solutions
J2EE Platform Overview (Application Architecture)
Databases and DBMSs Todd S. Bacastow January 2005.
New Technology: Why, What ,How
AlCaDB/PdmV meeting Thursday, 26 April 2012 Student: Aidas Tilmantas
Laravel vs CodeIgniter: Best of 2017
Yii.
MVC Architecture, Symfony Framework for PHP Web Apps
IS1500: Introduction to Web Development
Scripted Page Web App Development (Java Server Pages)
Web Software Model CS 4640 Programming Languages for Web Applications
Content Management System
Haritha Dasari Josue Balandrano Coronel -
Introduction to MVC PHP Web Development Ivan Yonkov Training Manager
Microsoft Office Illustrated
Populating a Data Warehouse
Populating a Data Warehouse
Data, Databases, and DBMSs
Web Browser server client 3-Tier Architecture Apache web server PHP
Populating a Data Warehouse
Lecture 1: Multi-tier Architecture Overview
Declarative Creation of Enterprise Applications
Web Application Architectures
The Model Layer What is Model?
Objective Understand web-based digital media production methods, software, and hardware. Course Weight : 10%
LitwareHR v2: an S+S reference application
Web Application Architectures
Web Application Architectures
Presentation transcript:

Web Applications Best Practices Martin Kruliš by Martin Kruliš (v1.2) 05.12.2016

Application Design Front Controller Design Pattern Advantages Application has a single point of entry (index.php) All requests are directed to this script (bootstrap) E.g., using mod_rewrite in Apache configuration Bootstrap script ensures routing and dispatching Routing – selection of target class (routine, method, …) Dispatching – invocation of target (loading script, …) Different handling for GET and POST requests Advantages More secure (only one gate to fortify) Less error-prone for programmers by Martin Kruliš (v1.2) 05.12.2016

Can be optimized further with classes and annotations Front Controller Imperative vs Declarative Approach Imperative ~ sequence of commands Declarative ~ data definitions Declarative approach is often preferred Can be optimized further with classes and annotations Imperative switch ($_GET['page']) { case 'home': require 'home.php'; break; case 'settings': require 'settings.php'; ... } Declarative $pages = [ 'home' => 'home.php', 'settings' => 'settings.php', ... ]; $page = $_GET['page']; if (isset($pages[$page])) require $pages[$page]; Example by Martin Kruliš (v1.2) 05.12.2016

Templates Idea of Templates Template Systems Separate HTML (CSS, …) code from PHP scripts Division of work (HTML coders vs. PHP programmers) Template Systems PHP-based Template is also a PHP script PHP-template only includes data into the HTML Text-based Special tags in HTML {{tag_name}}, <%tag_name%> Processed by text-replacement functions Check out Latte templating system in Nette framework. It is a quite neat example of templating. Example by Martin Kruliš (v1.2) 05.12.2016

Database Implementing Data Models Direct SQL writing is inconvenient Better to use some data abstraction layer Object-relational Mapping (ORM) Tables are mapped to classes or singleton objects Rows are mapped to objects (constructed by tables) The corresponding classes has to be generated from the database schema (or vice versa) SELECT * FROM users WHERE id = 42; $user = Users::getInstance()->get(42); For ORM example check out Doctrine (http://www.doctrine-project.org/). by Martin Kruliš (v1.2) 05.12.2016

Database Implementing Data Models NotORM (by Jakub Vrána) Keeping classes and DB schema in sync is very tedious in ORM systems Another approach is to use universal object mapping using dynamic features of PHP $users = $db->users() ->select("id, login, name") ->where("active", true) ->order("name"); foreach ($users as $id => $user) echo $user["name"], "\n"; For NotORM chek out http://www.notorm.com/ or dababase API in Nette. by Martin Kruliš (v1.2) 05.12.2016

Programming Practices Dependency Injection Software design pattern Principles of component-based programming Removes hard-wired dependencies from the code Decoupling the code Make it more coherent, robust, and less error-prone Dependent (consumer) declares list of dependencies As interface contracts (services it requires) Injector (provider) creates instances of requested services and provide them to the consumer I.e., injector is responsible for assembling components by Martin Kruliš (v1.2) 05.12.2016

Programming Practices Dependency Injection Example – database connection service Centralized Solution $db = mysqli_connect(...); ... function get_users() { global $db; mysqli_query($db, ...); } DI Solution $db = mysqli_connect(...); ... function get_users($db) { mysqli_query($db, ...); } DI becomes even more important and interesting when objects and classes are used by Martin Kruliš (v1.2) 05.12.2016

Application Development Software Engineering Approach Analysis Gathering/anticipating user requirements Pay extra attention to scaling problems Development Use appropriate scope Trivial inline PHP for trivial applications, robust frameworks and design patterns for complex applications Testing User/Application Testing (e.g., Selenium) Unit testing (e.g., PHPUnit) Continuous Integration (e.g., Travis CI) by Martin Kruliš (v1.2) 05.12.2016

Discussion by Martin Kruliš (v1.2) 05.12.2016