Upload
jo-erik-san-jose
View
504
Download
1
Embed Size (px)
DESCRIPTION
A simple presentation about introduction to PHP OOP and github
Citation preview
Why PHP?
What does PHP stand for?
Personal HomepagePHP: Hypertext Preprocessor (recursive
acronym)Created by Rasmus Lerdorf (1994)
It’s FREE!!
PHP is open-source
Platform Independent
Can be deployed/installed in different OS
Great Documentation
php.netFunctions are well explained + informative
examples
Large and Active Community
stackoverflowphp.netgithubEtc...
Easy to learn
Simple syntaxWell documentedLots of tutorials
everywhereLots of premade libraries
WHY PHP
It’s FreePlatform IndependentGreat DocumentationLarge and Active CommunityEasy to learn
OBJECT ORIENTED PROGRAMMING
Object Oriented Programming
A programming concept that treats functions and data as objects.
A programming methodology based on objects, instead of functions and procedures.
“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.”
Object and Class
CLASS
is a "template"/"blueprint" that is used to create objects
usually represents a noun, such as person, place or thing.
CLASS
class PointGuard{
}
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
Give examples of real life class and object.
INSTANCE
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
$instance = new PointGuard();
INHERITANCE
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)
INHERITANCE
<?phpclass BasketballPosition{ // some methods and properties}
class PointGuard extends BasketballPosition{ // some methods and properties}
Give examples of inheritance.
Class Properties and Methods
HeightWeightPassDribbleShootReboundBlock
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.
Class Properties
class PointGuard{ public $name; public $ball_handling_level;}
Class Methods
functions that are associated with the classfunctions that can be involve in the class
property processing
Class Methods
class PointGuard{ public $name; public $ball_handling_level;
public function createPlay() { // some processing here }}
Encapsulation
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.
Encapsulation
Example :Courting a girl
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
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
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
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
Choosing the Right Visibility
START
Accessed externally?
publicY
Deny to children?
privateY
N
N
protected
PHP OOP
Object and ClassInstanceInheritanceClass Properties and MethodsEncapsulation
Introduction to Git 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
Github eeeeee??
is a web-based hosting service for software development projects that use the Git revision control system
“social coding”
Why u no use git 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.
Why u no use git 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.
Why u no use git and github??
Why u no use git 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
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
“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