Web Systems Development (CSC-215)

Slides:



Advertisements
Similar presentations
PHP functions What are Functions? A function structure:
Advertisements

OOP Abstraction Classes Class Members: Properties & Methods Instance (object) Encapsulation Interfaces Inheritance Composition Polymorphism Using Inheritance.
Object Oriented Programming in PHP 5
Web Programming Language Week 6 Dr. Ken Cosh PHP Functions & Objects.
1 Chapter 6: Extending classes and Inheritance. 2 Basics of Inheritance One of the basic objectives of Inheritance is code reuse If you want to extend.
PACS – 10/19/131 Object-Oriented Programming “Object-oriented programming opens the door to cleaner designs, easier maintenance, and greater code reuseability.”
ACM/JETT Workshop - August 4-5, :Inheritance and Interfaces.
Object-Oriented PHP (1)
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Aalborg Media Lab 23-Jun-15 Inheritance Lecture 10 Chapter 8.
Inheritance and interfaces A class C1 is derived from class C2, then C1 is called subclass, and C2 is called superclass Superclass-parent, base class Subclass.
OOP in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Shallow Versus Deep Copy and Pointers Shallow copy: when two or more pointers of the same types point to the same memory – They point to the same data.
Chapter 12: Adding Functionality to Your Classes.
1 Inheritance and Polymorphism Chapter 9. 2 Polymorphism, Dynamic Binding and Generic Programming public class Test { public static void main(String[]
Chapter 15 – Inheritance, Virtual Functions, and Polymorphism
“is a”  Define a new class DerivedClass which extends BaseClass class BaseClass { // class contents } class DerivedClass : BaseClass { // class.
Chapter 8 More Object Concepts
CSCI-383 Object-Oriented Programming & Design Lecture 14.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
OOP IN PHP `Object Oriented Programming in any language is the use of objects to represent functional parts of an application and real life entities. For.
Inheritance The Basics in Java. Definition  A class that is derived from another class is called a subclass (also a derived class, extended class, or.
2010/11 : [1]Building Web Applications using MySQL and PHP (W1)OO PHP PHP Classes and Object Orientation.
8. Inheritance “Is-a” Relationship. Topics Creating Subclasses Overriding Methods Class Hierarchies Abstract Class Inheritance and GUIs The Timer Class.
1. 2  Classes are not just containers for methods ◦ Virtually all are classes ◦ Blueprint/Cookie Cutter/Recipe ◦ Objects – instance of the class (new)
Chapter 10: Classes and Data Abstraction. Objectives In this chapter, you will: Learn about classes Learn about private, protected, and public members.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 9 Java Fundamentals Objects/ClassesMethods Mon.
Chapter 7: Class Inheritance F Superclasses and Subclasses F Keywords: super and this F Overriding methods F The Object Class F Modifiers: protected, final.
CS-1030 Dr. Mark L. Hornick 1 Basic C++ State the difference between a function/class declaration and a function/class definition. Explain the purpose.
CSCI 3328 Object Oriented Programming in C# Chapter 9: Classes and Objects: A Deeper Look – Exercises 1 Xiang Lian The University of Texas Rio Grande Valley.
JAVA Programming (Session 4) “When you are willing to make sacrifices for a great cause, you will never be alone.” Instructor: รัฐภูมิ เถื่อนถนอม
Inheritance in Java. Access Specifiers private keywordprivate keyword –Used for most instance variables –private variables and methods are accessible.
Classes, Interfaces and Packages
Chapter 10: Classes and Data Abstraction. Classes Object-oriented design (OOD): a problem solving methodology Objects: components of a solution Class:
In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The import statement and using prewritten.
Inheritance in C++ Bryce Boe 2012/08/28 CS32, Summer 2012 B.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 10 Java Fundamentals Objects/ClassesMethods.
Object-Oriented Programming: Classes and Objects.
Java Programming: Guided Learning with Early Objects Chapter 9 Inheritance and Polymorphism.
Review for Test2. Scope 8 problems, 60 points. 1 Bonus problem (5 points) Coverage: – Test 1 coverage – Exception Handling, Switch Statement – Array of.
OOP: Encapsulation &Abstraction
Programming with ANSI C ++
Java Primer 1: Types, Classes and Operators
PHP Classes and Objects
Web Systems Development (CSC-215)
Inheritance, Polymorphism, and Interfaces. Oh My
Web Systems Development (CSC-215)
Web Systems Development (CSC-215)
Chapter 9 Inheritance and Polymorphism
Web Systems Development (CSC-215)
Web Systems Development (CSC-215)
Web Systems Development (CSC-215)
Interface.
Java Programming Language
Web Systems Development (CSC-215)
Andy Wang Object Oriented Programming in C++ COP 3330
Web Systems Development (CSC-215)
CSCI 3328 Object Oriented Programming in C# Chapter 9: Classes and Objects: A Deeper Look – Exercises UTPA – Fall 2012 This set of slides is revised from.
CSCI 297 Scripting Languages Day Seven
The University of Texas – Pan American
Java Programming, Second Edition
Object-Oriented Programming in PHP
Fundaments of Game Design
CSC212 Data Structure - Section RS
Java Programming Language
Andy Wang Object Oriented Programming in C++ COP 3330
Final and Abstract Classes
Classes and Objects Imran Rashid CTO at ManiWeber Technologies.
ENERGY 211 / CME 211 Lecture 17 October 29, 2008.
Object Oriented Programming (OOP) Lecture No. 12
Presentation transcript:

Web Systems Development (CSC-215) Lecture 4: Functions and Objects Monday 12th February 2018

Class Test 1 Monday 19th February Lab based – bring laptops or have desktop ready Lectures 1-6 Duration: 30 minutes

Setting up netbeans with wampserver for debugging

A note on type casting

Implicit & Explicit Casting PHP is loosely typed Variable and its type is declared simply by using it Automatically converts types when needed, via implicit casting

What if this behavior causes problems in some situations? We need a way to override. What if this behavior causes problems in some situations?

Explicit Casting Script produces a float value (attempts to produce the most accurate result) What if you need an integer value?

Explicit Casting

PHP Cast Types

Php functions & objects

Defining a Function

Example: Cleaning up a full name

Returning an array

Passing by reference

Including & requiring files

Include Statement

Include Once

Require and require once Program continues to execute even if the include failed (will then fail where it was needed)

Check if function exists Because PHP is evolving rapidly

Php objects

Creating Objects

Accessing Objects

Cloning Objects Assigning will create an additional reference

Not working

Use clone to create new instances

Constructors

Destructors

This

Static methods Called on class, not object

Implicit property definition - allowed by PHP but bad programming practice

Constants in class

Property & Method Scope Public Outside code accesses Extending classes should inherit Protected Outside code should not access Private Extending classes should not inherit

Usage

Inheritance Deriving subclasses from pre-existing classes Only modify the parts that are different Using extends operator

The parent operator A method in a subclass with the same name as one in its parent class will override the parent class method The parent operator can be used to access the parent method if this behavior is not desired

Parent constructors must be called explicitly when needed

Prevent overriding by subclass

Lecture content adapted from chapter 5 of Learning PHP, MySQL, JavaScript, CSS & HTML5, 3rd Edition, by Robin Nixon.