SlideShare a Scribd company logo
Web Design
and
Development
By: Shahrzad Peyman
Session 9
December-2017
shahrzad.peymaan@gmail.com
1
2
Today’s Presentation
• self
• Inheritance
• Access Level
• Interface
• Abstract
• Trait
Constructor
3
When creating a new object, you can pass a list
of arguments to the class being called. These are
passed to a special method within the class,
called the constructor, which initializes various
properties.
Static Method
4
You can also define a method as static, which
means that it is called on a class, not on an
object. A static method has no access to any
object properties and is created and accessed as
in below example:
Declaring Constants
5
You can define constants inside classes. The
generally accepted practice is to use uppercase
letters to make them stand out.
Encapsulation
6
In basic terms, it’s the way we define the visibility of
our properties and methods.
• When you’re creating classes, you have to ask
yourself what properties and methods can be
accessed outside of the class.
Access Level
7
Specifier Class SubClass all
Private *
Protected * *
Public * * *
Inheritance
• In object-oriented programming, inheritance
is when a class is based on another class,
using the same implementation or specifying
a new implementation to maintain the same
behavior.
• Such an inherited class is called a subclass
of its parent class or super class.
8
Inheritance
9
Inheritance
10
11
Interface
An interface is an outline of what a particular
object can do. You will often hear that an
interface is a contract. This is true in as much
as an interface defines the public methods that
a class must implement.
Object interfaces allow you to create code
which specifies which methods a class must
implement, without having to define how these
methods are handled.
Interface
12
Abstract
13
An abstract class is a special type of class that can't
be instantiated — in other words, you can't create
objects from it. Instead, you create child classes
from the abstract class, and create objects from
those child classes instead.
An abstract class is designed to be used as a
template for creating classes.
An abstract class will have abstract methods which
are defined by the abstract keyword, these methods
are like the methods defined in the interface classes.
14
Abstract
Interface vs Abstract
Interface Abstract
The Code
• abstract methods
• constants
• abstract methods
• constants
• concrete methods
• concrete variables
Access Modifiers • public
• public
• private
• protected
Number of Parents
Class can impelement
more than one interface
Class can inherit only
from one abstract class
15
Trait
16
One of the problems of PHP as a programming
language is the fact that you can only have
single inheritance. This means a class can only
inherit from one other class.
However, a lot of the time it would be beneficial
to inherit from multiple classes. For example, it
might be desirable to inherit methods from a
couple of different classes in order to prevent
code duplication.
17
Trait
A Trait is simply a group of methods that you
want include within another class.

More Related Content

PDF
Web Design & Development - Session 8
PDF
Object Oriented Programming with Laravel - Session 1
PDF
Web Design & Development - Session 7
PDF
Object Oriented Programming with Laravel - Session 3
PPTX
Web-Dev Portfolio
PPTX
Oopsinphp
PPTX
Web Design & Development - Session 8
Object Oriented Programming with Laravel - Session 1
Web Design & Development - Session 7
Object Oriented Programming with Laravel - Session 3
Web-Dev Portfolio
Oopsinphp

What's hot (20)

PDF
Javascript Roadmap - The Basics
PPT
Tech talk webtech
PPT
Object oriented vs. object based programming
PDF
Carlos Amador .Net Portfolio
PPT
Tech talk php_cms
PDF
JavaScript - Chapter 12 - Document Object Model
PDF
CSS: selectors and the box model
PDF
CSS3 and Selectors
PPTX
Web Front End
PDF
Object-oriented programming (OOP) with Complete understanding modules
PPTX
Coding conventions
PPTX
25 php interview questions – codementor
PPT
Oops
PPTX
Coding conventions
PPTX
Object Oriented Programming in Java _lecture 1
PPTX
DSL in test automation
PPT
PhD Presentation
Javascript Roadmap - The Basics
Tech talk webtech
Object oriented vs. object based programming
Carlos Amador .Net Portfolio
Tech talk php_cms
JavaScript - Chapter 12 - Document Object Model
CSS: selectors and the box model
CSS3 and Selectors
Web Front End
Object-oriented programming (OOP) with Complete understanding modules
Coding conventions
25 php interview questions – codementor
Oops
Coding conventions
Object Oriented Programming in Java _lecture 1
DSL in test automation
PhD Presentation
Ad

Similar to Web Design & Development - Session 9 (20)

PPTX
Php oop (1)
PDF
When & Why: Interfaces, abstract classes, traits
PPTX
2CPP09 - Encapsulation
PPTX
Object Oriented Programming C#
PPTX
Object-oriented programming 3.pptx
PPTX
JS Design patterns in Web technologies including oop techniques.pptx
PPTX
Design patterns Structural
PPTX
Object oriented programming
PDF
The View object orientated programming in Lotuscript
PPTX
Software enginnnering introduction (2).pptx
PPTX
chapter 5 concepts of object oriented programming
PPTX
OOP interview questions & answers.
PPTX
OCP Java (OCPJP) 8 Exam Quick Reference Card
PPTX
Object Oriented Programming
PPTX
Introduction to OOP concepts
DOC
Questpond - Top 10 Interview Questions and Answers on OOPS
PPTX
SKILLWISE - OOPS CONCEPT
PPTX
Jscript part2
PPTX
Unusual C# - OOP
Php oop (1)
When & Why: Interfaces, abstract classes, traits
2CPP09 - Encapsulation
Object Oriented Programming C#
Object-oriented programming 3.pptx
JS Design patterns in Web technologies including oop techniques.pptx
Design patterns Structural
Object oriented programming
The View object orientated programming in Lotuscript
Software enginnnering introduction (2).pptx
chapter 5 concepts of object oriented programming
OOP interview questions & answers.
OCP Java (OCPJP) 8 Exam Quick Reference Card
Object Oriented Programming
Introduction to OOP concepts
Questpond - Top 10 Interview Questions and Answers on OOPS
SKILLWISE - OOPS CONCEPT
Jscript part2
Unusual C# - OOP
Ad

More from Shahrzad Peyman (9)

PDF
Web Design & Development - Session 6
PDF
Web Design & Development - Session 4
PDF
Web Design & Development - Session 3
PDF
Web Design & Development - Session 2
PDF
Web Design & Development - Session 1
PDF
Object Oriented Programming with Laravel - Session 6
PDF
Object Oriented Programming with Laravel - Session 5
PDF
Object Oriented Programming with Laravel - Session 4
PDF
Object Oriented Programming with Laravel - Session 2
Web Design & Development - Session 6
Web Design & Development - Session 4
Web Design & Development - Session 3
Web Design & Development - Session 2
Web Design & Development - Session 1
Object Oriented Programming with Laravel - Session 6
Object Oriented Programming with Laravel - Session 5
Object Oriented Programming with Laravel - Session 4
Object Oriented Programming with Laravel - Session 2

Recently uploaded (20)

PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Cost to Outsource Software Development in 2025
PPTX
Advanced SystemCare Ultimate Crack + Portable (2025)
PPTX
history of c programming in notes for students .pptx
PPTX
Oracle Fusion HCM Cloud Demo for Beginners
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Salesforce Agentforce AI Implementation.pdf
PDF
Autodesk AutoCAD Crack Free Download 2025
PDF
Digital Systems & Binary Numbers (comprehensive )
DOCX
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
PPTX
CHAPTER 2 - PM Management and IT Context
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
PPTX
Patient Appointment Booking in Odoo with online payment
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Designing Intelligence for the Shop Floor.pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
How to Choose the Right IT Partner for Your Business in Malaysia
Cost to Outsource Software Development in 2025
Advanced SystemCare Ultimate Crack + Portable (2025)
history of c programming in notes for students .pptx
Oracle Fusion HCM Cloud Demo for Beginners
Reimagine Home Health with the Power of Agentic AI​
Salesforce Agentforce AI Implementation.pdf
Autodesk AutoCAD Crack Free Download 2025
Digital Systems & Binary Numbers (comprehensive )
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
CHAPTER 2 - PM Management and IT Context
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
Patient Appointment Booking in Odoo with online payment
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Designing Intelligence for the Shop Floor.pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025

Web Design & Development - Session 9

  • 2. 2 Today’s Presentation • self • Inheritance • Access Level • Interface • Abstract • Trait
  • 3. Constructor 3 When creating a new object, you can pass a list of arguments to the class being called. These are passed to a special method within the class, called the constructor, which initializes various properties.
  • 4. Static Method 4 You can also define a method as static, which means that it is called on a class, not on an object. A static method has no access to any object properties and is created and accessed as in below example:
  • 5. Declaring Constants 5 You can define constants inside classes. The generally accepted practice is to use uppercase letters to make them stand out.
  • 6. Encapsulation 6 In basic terms, it’s the way we define the visibility of our properties and methods. • When you’re creating classes, you have to ask yourself what properties and methods can be accessed outside of the class.
  • 7. Access Level 7 Specifier Class SubClass all Private * Protected * * Public * * *
  • 8. Inheritance • In object-oriented programming, inheritance is when a class is based on another class, using the same implementation or specifying a new implementation to maintain the same behavior. • Such an inherited class is called a subclass of its parent class or super class. 8
  • 11. 11 Interface An interface is an outline of what a particular object can do. You will often hear that an interface is a contract. This is true in as much as an interface defines the public methods that a class must implement. Object interfaces allow you to create code which specifies which methods a class must implement, without having to define how these methods are handled.
  • 13. Abstract 13 An abstract class is a special type of class that can't be instantiated — in other words, you can't create objects from it. Instead, you create child classes from the abstract class, and create objects from those child classes instead. An abstract class is designed to be used as a template for creating classes. An abstract class will have abstract methods which are defined by the abstract keyword, these methods are like the methods defined in the interface classes.
  • 15. Interface vs Abstract Interface Abstract The Code • abstract methods • constants • abstract methods • constants • concrete methods • concrete variables Access Modifiers • public • public • private • protected Number of Parents Class can impelement more than one interface Class can inherit only from one abstract class 15
  • 16. Trait 16 One of the problems of PHP as a programming language is the fact that you can only have single inheritance. This means a class can only inherit from one other class. However, a lot of the time it would be beneficial to inherit from multiple classes. For example, it might be desirable to inherit methods from a couple of different classes in order to prevent code duplication.
  • 17. 17 Trait A Trait is simply a group of methods that you want include within another class.