50
Why PHP?

Intro to OOP PHP and Github

Embed Size (px)

DESCRIPTION

A simple presentation about introduction to PHP OOP and github

Citation preview

Page 1: Intro to OOP PHP and Github

Why PHP?

Page 2: Intro to OOP PHP and Github

What does PHP stand for?

Personal HomepagePHP: Hypertext Preprocessor (recursive

acronym)Created by Rasmus Lerdorf (1994)

Page 3: Intro to OOP PHP and Github

It’s FREE!!

PHP is open-source

Page 4: Intro to OOP PHP and Github

Platform Independent

Can be deployed/installed in different OS

Page 5: Intro to OOP PHP and Github

Great Documentation

php.netFunctions are well explained + informative

examples

Page 6: Intro to OOP PHP and Github

Large and Active Community

stackoverflowphp.netgithubEtc...

Page 7: Intro to OOP PHP and Github

Easy to learn

Simple syntaxWell documentedLots of tutorials

everywhereLots of premade libraries

Page 8: Intro to OOP PHP and Github

WHY PHP

It’s FreePlatform IndependentGreat DocumentationLarge and Active CommunityEasy to learn

Page 9: Intro to OOP PHP and Github

OBJECT ORIENTED PROGRAMMING

Page 10: Intro to OOP PHP and Github

Object Oriented Programming

A programming concept that treats functions and data as objects.

A programming methodology based on objects, instead of functions and procedures.

Page 11: Intro to OOP PHP and Github

“I explain that procedural program is built around the "verbs" of the system, the things you want the system to do, whereas object-oriented programming is build about the "nouns," the things in the system, and what they are capable of.”

Page 12: Intro to OOP PHP and Github

Object and Class

Page 13: Intro to OOP PHP and Github

CLASS

is a "template"/"blueprint" that is used to create objects

usually represents a noun, such as person, place or thing.

Page 14: Intro to OOP PHP and Github

CLASS

class PointGuard{

}

Page 15: Intro to OOP PHP and Github

OBJECT

In real world object is a material thing that can be seen and  touched.

In OOP, object is a self-contained entity that consist of both data and procedures.

An instance of a class

Page 16: Intro to OOP PHP and Github

Give examples of real life class and object.

Page 17: Intro to OOP PHP and Github

INSTANCE

Page 18: Intro to OOP PHP and Github

INSTANCE

layman's term - a case or occurrence of anything

a single copy of an object, there might be one or several  objects, but an instance is a specific copy, to which you can have a reference

Page 19: Intro to OOP PHP and Github

$instance = new PointGuard();

Page 20: Intro to OOP PHP and Github

INHERITANCE

Page 21: Intro to OOP PHP and Github

INHERITANCE

biology - the genetic characters transmitted from parents to offspring

OOP - provides reusability of codes. We can add additional codes to an existing class without modifying it.  

can be defined as the process of one object acquires the properties of another by making subclasses (parent-child relationship)

Page 22: Intro to OOP PHP and Github

INHERITANCE

<?phpclass BasketballPosition{ // some methods and properties}

class PointGuard extends BasketballPosition{ // some methods and properties}

Page 23: Intro to OOP PHP and Github

Give examples of inheritance.

Page 24: Intro to OOP PHP and Github

Class Properties and Methods

HeightWeightPassDribbleShootReboundBlock

Page 25: Intro to OOP PHP and Github

Class Properties

 also know as data members and is used to hold data of a class.

The data that it holds are specific to the nature of the class in which it has been defined.

Page 26: Intro to OOP PHP and Github

Class Properties

class PointGuard{ public $name; public $ball_handling_level;}

Page 27: Intro to OOP PHP and Github

Class Methods

functions that are associated with the classfunctions that can be involve in the class

property processing

Page 28: Intro to OOP PHP and Github

Class Methods

class PointGuard{ public $name; public $ball_handling_level;

public function createPlay() { // some processing here }}

Page 29: Intro to OOP PHP and Github

Encapsulation

Page 30: Intro to OOP PHP and Github

Encapsulation

 facilitates the bundling of data with the methods (or other functions) operating on that data.

 restricting access to some of the object’s components.

used to hide the values or state of a structured data object inside a class, preventing unauthorized parties' direct access to them.

Page 31: Intro to OOP PHP and Github

Encapsulation

Example :Courting a girl

Page 32: Intro to OOP PHP and Github

Encapsulation

Access modifiers/Visibility private

property and method can be accessed only inside the class itself and can't be accessed anywhere else

protected property and method can be accessed only

inside the class itself and inside child classes. public

allows the property/method to be accessed from anywhere of code

Page 33: Intro to OOP PHP and Github

Private

class Love{ private $hearbeat_per_second = 100;

public function getHeartBeatPerSec() { return $this->heartbeat_per_second; }}

class Valentines extends Love{ public function getHeartBeatPerSecWhenNear() { return $this->heartbeat_per_second * 2; // will produce an error }}

$love = new Love();echo $love->getHeartBeatPerSec(); // will output 100echo $love->heartbeat_per_second; // will produce an error

Page 34: Intro to OOP PHP and Github

Protected

class Love{ protected $hearbeat_per_second = 100;

public function getHeartBeatPerSec() { return $this->heartbeat_per_second; }}

class Valentines extends Love{ public function getHeartBeatPerSecWhenNear() { return $this->heartbeat_per_second * 2; // will return 200 }}

$love = new Love();echo $love->getHeartBeatPerSec(); // will output 100echo $love->heartbeat_per_second; // will produce an error

Page 35: Intro to OOP PHP and Github

Public

class Love{ public $hearbeat_per_second = 100;

public function getHeartBeatPerSec() { return $this->heartbeat_per_second; }}

class Valentines extends Love{ public function getHeartBeatPerSecWhenNear() { return $this->heartbeat_per_second * 2; // will return 200 }}

$love = new Love();echo $love->getHeartBeatPerSec(); // will output 100echo $love->heartbeat_per_second; // will output 100

Page 36: Intro to OOP PHP and Github

Choosing the Right Visibility

START

Accessed externally?

publicY

Deny to children?

privateY

N

N

protected

Page 37: Intro to OOP PHP and Github

PHP OOP

Object and ClassInstanceInheritanceClass Properties and MethodsEncapsulation

Page 38: Intro to OOP PHP and Github

Introduction to Git and Github

Page 39: Intro to OOP PHP and Github

Git whhaaat???

Is a source/version control management software.

Is a software that allows you to track the changes that you make to individual files.

git push

git pull

git commit

Page 40: Intro to OOP PHP and Github

Github eeeeee??

 is a web-based hosting service for software development projects that use the Git revision control system

“social coding”

Page 41: Intro to OOP PHP and Github

Why u no use git and github??

Page 42: Intro to OOP PHP and Github

Why u no use git and github??

Git can track your changes to your projects.You can go back to a certain change you

made that you want to recover.

Page 43: Intro to OOP PHP and Github

Why u no use git and github??

Page 44: Intro to OOP PHP and Github

Why u no use git and github??

Github lets you collaborate with other developers or your project teammates by adding comments or suggestions on commits.

You can also contribute to public/open source projects. (eg. Facebook SDK, Codeigniter, PHP, etc...)

Share your codes to public and get feedback from large community of developers.

Page 45: Intro to OOP PHP and Github

Why u no use git and github??

Page 46: Intro to OOP PHP and Github

Why u no use git and github??

Page 47: Intro to OOP PHP and Github

Commands Overview

git init Initializes a git repository.

git status Check your changes made (untracked files, modified files, staged

files) git commit

Save your changes into one commit history. git push

Push your changes in the remote repository. git pull

Pull changes from remote repository and apply it to your local repository.

git fetch Fetch changes from remote repository but changes will not apply

to your local repository

Page 48: Intro to OOP PHP and Github

Git and Github

Git and github can be effectively used in project collaborations.

Can improve a developer’s coding.Can avoid overriding or duplicating codesNot just a developer tool

Page 49: Intro to OOP PHP and Github

“Whenever you are asked if you can do a job, tell'em, Certainly, I can! Then get busy and find out how to do it.”

- Theodore Roosevelt

Page 50: Intro to OOP PHP and Github