Skip to content

AdriAparicioPons/oop-basics

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#php #oop #master-in-software-engineering

Assembler School: OOP Basics with PHP

In this project you will learn the basics of OOP using mobile devices as a reference. In the "Project files" section you will find a description of the content to be displayed in each file.

Table of contents

Getting Started

The repo

First, you will need to clone the repo:

$ git clone https://github.com/assembler-school/oop-basics.git

Presentation material

Dependencies

Before we can get started you will need to make sure that all the necessary dependencies are installed in your system.

PHP

You can install it by following the instructions in the official docs (we recommend that you install the version that is named Current).

To verify that you have installed it correctly, you can run the following command from the terminal that should output the version installed:

$ php -version

Tools

In the event that you prefer to use a tool that installs everything you need to configure and run a PHP server, we recommend using XAMPP

XAMPP

XAMPP is a completely free and easy to install Apache distribution that contains MariaDB, PHP, and Perl. The XAMPP installation package has been designed to be incredibly easy to install and use.

xampp homepage

You have to go to the download page and it will automatically recommend installing the latest version available.

xampp download

Once downloaded and installed, in the case that the Windows operating system you will see the following screen, in which you will only have to start the Apache service.

xampp app

OOP Introduction

Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects", which can contain data and code: data in the form of fields (often known as attributes or properties), and code, in the form of procedures (often known as methods).

Project files

The OOP paradigm encapsulates concepts of the real world in what is called as Classes which create Objects. In this file you will learn how to create a class and instanciate it.

Class member variables are called properties. In this file, you will learn how to add properties to a class and get them when the class is instantiated.

Properties define the characteristics of an object and the methods (functions in a class are called methods) which define the behavior of the Class. In this file you will learn how to create methods inside a class.

The get method returns the attribute value, usually there is a get method for each attribute of the class. In this file you will learn how to create getter methods.

The set method sets the attribute value, usually there is a get method for each attribute of the class. In this file you will learn how to create setter methods.

A constructor allows you to initialize an object's properties upon creation of the object. In this file you will learn how to create the constructor method.

There are several disadvantages of not applying inheritance in our code. In this file you will lean what's the problem if you don't apply any inheritance in your code.

The child class will inherit all the public and protected properties and methods from the parent class. In addition, it can have its own properties and methods. In this file you will learn how to apply the inheritance in your code.

Properties and methods can have access modifiers which control where they can be accessed. In this file you will learn le three access modifiers.

Static properties and methods can be called directly - without creating an instance of the class first. In this file you will learn how to use static properties and methods.

Constants cannot be changed once it is declared. Class constants can be useful if you need to define some constant data within a class. In this file you will learn how to create constants within a class.

Abstract classes and methods are when the parent class has a named method, but need its child class(es) to fill out the tasks. In this file you will learn how to create and use abstract classes.

Interfaces allow you to specify what methods a class should implement. Interfaces make it easy to use a variety of different classes in the same way. When one or more classes use the same interface, it is referred to as "polymorphism". In this file you will learn how to create and extend interfaces.

In function overriding, both parent and child classes should have same function name with and number of arguments. In this file you will learn how to implement overriding.

Function overloading contains same function name and that function preforms different task according to number of arguments. In this file you will learn how to implement overloading.

Namespaces are qualifiers that solve two different problems:

  1. They allow for better organization by grouping classes that work together to perform a task
  2. They allow the same name to be used for more than one class

In this file you will learn how to create and use namespaces.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%