1 / 80

Web Technology Solutions

Web Technology Solutions. Class: Three-Tier Application Architecture and more PHP Programming Practice. Date : 1/12/2012. Tonight. Three Tier Architecture PHP and its oppositionPHP Syntax Review and Simple Debugging Techniques.Lab. Lab Preview.

tim
Download Presentation

Web Technology Solutions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Web Technology Solutions • Class: Three-Tier Application Architecture and more PHP Programming Practice Date : 1/12/2012

  2. Tonight • Three Tier Architecture PHP and its oppositionPHP Syntax Review and Simple Debugging Techniques.Lab

  3. Lab Preview • PHP Basics: Working with variables, conditionals, managing arrays, clean commenting, and debugging. • Homework: documentation and design.

  4. System Recap • software system is a collection of interacting software components. Recall that the components of a system can also be considered as systems, called subsystems. Those subsystems (components) of a system that directly interact with each other do so through interfaces

  5. Server Side Systems • Allow for High Availability(HA), Dynamic Data Interaction, Data Storage Modern web apps excel at all three - twitter, Facebook, digg, flickr, etc

  6. Web Applications Systems

  7. Which Systems To Use?

  8. Selecting Systems • Being a technologist is understanding which system offers their client the maximum of benefits. How do you choose? • Modern Web Applications collect various subsystems and make them their own system. • Solves for HA, Interaction, Storage and Retrieval.

  9. Application Architecture

  10. System Models • An Architecture Defines: What Important Systems are Needed and their Interfaces. • A model is a simplified way to represent or think about a system of interest. Models are often represented using diagrams to show how components are related and organized. • Two System Examples: Web App, Databases.

  11. Example System

  12. Common Models • Database

  13. Common Models • Web Servers

  14. Common Models • Internet

  15. Common Models • Load Balancer

  16. Web Systems • Web Applications should scale gracefully. LAMP allows for that • Note: the load balancer • Multiple Redundant Web Servers • Multiple DBs (master and slave) • What is missing? CDN’s

  17. MySQL Example • MySQL comes with many sub-systems

  18. How to Document a Model • Models and Architecture add value as design documents. • Include only the most important components of a system. • Hide Details

  19. How to Document a Model • Hide the details • Reduce complexity and increases conceptualization making for easy buy-off. • Avoid information overload • Stakeholders and non-techies don’t care. • Example: Three Tier system

  20. 3-Tier Web System • Typical Web solution where each tier provides specific types of service. • 1. Presentation Layer: produces the user interface • 2. Business Logic Layer: implements applications functionality • 3. Data services Layer: provides data storage for the application • Example: Detailed Model (note subsystems)

  21. Why PHP?

  22. PHP • PHP: Ubiquitous. Easy to host and learn. • PHP: tied in harmony to Linux, Apache, MySQL. Loads of devs and huge community. • PHP is criticized because it is not strict in its promotion of best-of-breed coding practices. See php.net comments. • PHP and PECL extend PHP • PHP is liberating to rapidly develop ‘simple sites’ but scalable web apps?

  23. PHP vs. Other • The debate with PHP vs. others. Understand each has their benefit. • Ruby • C# • Java • Python

  24. PHP vs. Ruby • PHP vs. Ruby (Rails) • Syntax akin to smalltalk. PHP is C based. • PHP easier to host (rails ssh, root) • PHP not strict. Ruby all OOP (everything object) • PHP has many frameworks, • Rails is MVC

  25. PHP vs. C# • PHP vs. C# (.net) • C# tied to the .NET framework • C# bindings to allow for desktop apps • Akin to Java in ability and behavior. • has an MVC framework.

  26. PHP vs. Python • PHP vs. Python (Django) • Python has strict syntax control structure • Python benchmarks • PHP primarily web based - python extends beyond the web. • Bad programmers are able to write bad programs in any language

  27. Best Practice • Bad PHP: Three layers all in one (spaghetti code) • Good PHP (MVC Design Pattern) • Presentation: Templates (minimal PHP) • Logic: All PHP to handle data transaction and state • Business: PHP is used to abstract the Database. No real native SQL calls. PHP can be used for good or bad.

  28. Best Practice Tip • Always develop a high level system architecture as part of the documentation deliverable. • Clients love to know you’re taking care of the details.

  29. Best Practice Tip • Prepare detailed low-level system and system diagrams for areas of risk or what I would be personally responsible for and will require prototyping. • risk: something I haven’t coded before

  30. Best Practice Tip • Focus on Rapid Application Development Techniques • Be Agile • Update quickly • Verify assumptions • Ask questions, find improvements

  31. Best Practice Tip • Keep Documentation Current. Things change!

  32. Final Project Documentation Start now. Lesson 3: Start documentingLesson 4: Much prototyping.Lesson 5: Documentation Complete.You’re building a professional application.

  33. Tools

  34. FTP • Mac • Transmit • Cyberduck • Coda • PC • SmartFTP • FileZilla • Firefox

  35. IDE • Mac • Coda • Eclipse • Textmate • Dreamweaver • PC • PHP Designer • Zend Developer • notepad++ \ dreamweaver

  36. Firebug a preview

  37. Programming PHP

  38. PHP on Linux: First Steps • Understanding how PHP is setup and configured on your installation of linux is critical to your success. • phpinfo() • php.ini • Denied function, extensions, modules.

  39. PHP Basics • All php code must start with <? • All php code must end with ?> • You might see <?php which is fine as well.

  40. PHP Basics • Every PHP statement must end in a semicolon? • echo “i love php”;

  41. PHP Basics • if a webpage contains PHP, keep the extension as .php • do not name it html.

  42. PHP Variables • Variables store basic units of data that can control an application • Variables in PHP start with a $ sign. Must start with char or _ • for example: $player • setting variable: $player = “poodle”; • variable reference: $player =& $music (points to same content in memory) • restricted: $this (used in classes) • destroy: unset();

  43. PHP Restricted Keywords • Abstract, And, array(), As, Break, Case, catch, cfunction, Class, clone, Const, Continue, Declare, Default, die(), Do, echo(), Else, elseif, empty, enddeclare, endfor, endforeach, endif, endswitch, endwhile,final, for, foreach, function, global, if

  44. HTTP GET • This method appends the form-data to the URL in name/value pairs • This method is useful for form submissions where a user want to bookmark the result • There is a limit to how much data you can place in a URL (varies between browsers), therefore, you cannot be sure that all of the form-data will be correctly transferred • Never use the "get" method to pass sensitive information! (password or other sensitive information will be visible in the browser's address bar)

  45. HTTP POST • This method sends the form-data as an HTTP post transaction • Form submissions with the "post" method cannot be bookmarked • The "post" method is more robust and secure than "get", and "post" does not have size limitations

  46. PHP Global Variables • Pre-Defined SuperGlobal Vars - available in all scope. • usually indicated by underscore and caps • $GLOBALS • $_SERVER • $_GET • $_POST • $_COOKIE • $_SESSION • $_FILES • $_ENV • old style from php3 $HTTP_COOKIE_VARS

  47. PHP Variables • Typically a variable has a lifespan of the current page (including pages that are inserted within the page you’re working). • In OOP there are extended definitions of a variable that restrict usage. • Golden Rule: Avoid the urge to scope globally.

  48. PHP Commenting • Super basic: • // this is a single line comment • /* this is a comment */ • /* • * this is a comment • */ • best practice: good commenting

  49. PHP Commenting • /* • * Dev: Lincoln Mongillo • * Time Updated: 09.12.08 2:30pm • * File: email-validation.php • * Desc: validates a users email address • */

  50. PHP Data Types • Booleans • Integers • Floats • Strings • Arrays • Objects • Resource

More Related