Presentation is loading. Please wait.

Presentation is loading. Please wait.

Web Technology Solutions

Similar presentations


Presentation on theme: "Web Technology Solutions"— Presentation transcript:

1 Web Technology Solutions
Class: OOP PHP, Design Patterns and CRUD Date : 02/09/2012

2 Tonight CRUD Redux Objects in PHP OOP Design Patterns Lab

3 Lab Preview Continue to build a simple CRUD app with the presidents table.

4 OOP in PHP Object Oriented Programming Objects and Classes
PHP4 vs PHP5 Design Patterns Example

5 OOP in PHP Objects are discrete bundles of functions relating a concept (database connections, image creation, managing users) Objects work together to create applications. Service multiple projects with a single set of code. Code is portable, encapsulated, reusable and easier to debug.

6 OOP Example

7 OOP Car Functions of a car Accelerate, Stop, Steering
How? (implementation) Gas Pedal, Engine Breaks Steering and Wheels Care how it works? No.

8 Object Oriented Programming
What is an object: A “copy” or “instance” of a class. Objects have properties (color, speed, horsepower, seats) Objects have methods (accelerate, stop, steering).

9 Object Oriented Programming
/* <?php * File Name: car * Date: November 18, 2010 * Author: Lincoln Mongillo * Description: Manages Car */ class Car { } ?>

10 Object Oriented Programming
<?php $myRaceCar = new Car(); $myRaceCar -> accelerate(55); ?>

11 Object Oriented Programming
Car = a basic blueprint that represents any car. color wheels seats horsepower With Car we can “create” other types of speciality cars: dump trucks, sports cars. How? Classes can “inherit” properties and methods from other classes.

12 Object Oriented Programming
Car wheels: 4 color: white seats: 4 horsepower: 8 race car truck wheels: 4 color: white seats: 2 horsepower: 200 wheels: 4 color: red seats: 8 horsepower: 100 wheels: 4 color: white seats: 4 horsepower: 200 wheels: 4 color: white seats: 4 horsepower: 200

13 Object Oriented Inheritance
/* <?php * File Name: RaceCar * Date: November 18, 2008 * Author: Lincoln Mongillo * Description: Manages RaceCars */ class RaceCar extends Car { } ?>

14 Object Oriented Polymorphism
A Truck vs. Race Car come from car. Extending a class allows for “Polymorphism” which allows you to perform different tasks based on the context you’re using it in. Example: stop() between truck vs. racecar is somewhat the same but different because of the nature of the truck (size) and racecar (speed). It might implement the method differently to get the result.

15 Object Oriented Encapsulation
Don’t need to know how it works (members functions or props) You just need to know what you can do (available methods - interface)

16 Object Oriented Encapsulation
How do you know what you can use? Levels of visibility public: means that a class member is visible and usable / modifiable by everyone - default in PHP private: means that a class member is only usable / modifiable by the class itself protected: means that a class member is only usable / modifiable by the class itself and eventual sub-classes

17 Class Constructor - PHP4
class Car { public function Car() { echo "We just created and object!"; } ?>

18 Class Constructor - PHP5
class Car {     function __construct() {           echo "We just created and object!";       }   } ?>

19 Class Constructor - Properties
class Car <?php { private $color;   private $wheels;   private $seats;       function __construct() {   $this->color = “OxFFFFF”; $this->wheels = 4;     }   } ?>

20 Class Constructor - Properties
    function __construct() {   $this->color = “OxFFFFF”; $this->wheels = 4; // $this is a reference to the object that is calling it. $truck = new Car(); // $this = truck.

21 Object Oriented Programming
Image Example Database Example

22 Lab & Next Week Please send me your Survey in word doc format.
Your personal DB will be updated next week and we will start working on the app.

23 Lab & Next Week Homework Complete Presidents CRUD system

24 Lab & Next Week Next week we will Create Registration system
Create Login w\ Encrypt Password. Security and Authorization Reading: Chapter 4,7, and 14 See you Tuesday!


Download ppt "Web Technology Solutions"

Similar presentations


Ads by Google