Introduction To Object-Oriented Programming With PHP

For many programmers, object-oriented programming is a frightening concept, full of complicated syntax and other roadblocks. We’ll be learning the concepts behind object-oriented programming (OOP), a style of coding in which related actions are grouped into classes to aid in creating more-compact, effective code.

Understanding Object-Oriented Programming

Object-oriented programming is a style of coding that allows developers to group similar tasks into classes. This helps keep code following the tenet “don’t repeat yourself” (DRY)and easy-to-maintain.

“Object-oriented programming is a style of coding that allows developers to group similar tasks into classes.”

One of the major benefits of DRY programming is that, if a piece of information changes in your program, usually only one change is required to update the code. One of the biggest nightmares for developers is maintaining code where data is declared over and over again, meaning any changes to the program become an infinitely more frustrating game of Where’s Waldo? as they hunt for duplicated data and functionality.

OOP is intimidating to a lot of developers because it introduces new syntax and, at a glance, appears to be far more complex than simple procedural, or inline, code. However, upon closer inspection, OOP is actually a very straightforward and ultimately simpler approach to programming

Why PHP?

Besides the fact that it is my programming language of choice, there are two reasons to start with PHP.

PHP is widely used

PHP is likely the most widely used server-side programming language (see this article, for example). It’s used on millions of servers world wide.

PHP is very popular in the open source world, where applications like WordPress and Drupal live. One reason is that PHP is itself open source.

This means that your PHP skills will have value to many different people (including you!).

PHP is (relatively) easy to learn

Make no mistake: programming is hard. For most people, anyway.

What people have trouble with is not the programming languages, but the way of thinking about program design. This only comes with practice, practice, and more practice.

But still, some languages are easier to learn than others. Java is one of the more difficult. It’s a good language, but it’s very structured, and hard for beginners to get started with.

Two of the easiest languages to learn are JavaScript and PHP. Even a few lines of JavaScript and PHP can do useful things. You can start writing programs quickly, without having to learn of lot of stuff first.

What you will need:

  1. A computer
  2. A development environment for PHP.

If you don’t have a development environment yet, never fear, you have 2 options.

  1. If you just want to play around and have reliable internet, Cloud 9 is a free online IDE (integrated development environment) that has everything you need and is quick and easy to set up. I have more detail explanation to set up Virtual development environment here.
  2. If you actually want to set up a LOCAL development environment on your machine please check out my detailed explanation here.
    This option is for you if:

    1. you want to be able to access you development environment offline
    2. you want more control over your environment
    3. you are a serious programming student and what to use an industry standard way of having development environments

Files used in class

Full PHP Script used in presentation (intro.php): https://github.com/sketchings/oop-basics

Lets Get Started

I’m excited to work with you all and building our skills together. If you have any questions or concerns, please let me know 🙂 If you are interested in taking this as a hands on workshop, I will be presenting this series at different venues in the Portland area, most are free, so please drop me an email and I will let you know about upcoming events.

Check out Part 1

Check out Part 2

Concusion / Evaluation

If you are interested in taking this as a hands on workshop, I will be presenting this series at different venues, mostly in the Portland area. Most are free, so please drop me an email and I will let you know about upcoming events.

If you HAVE taken the class, please fill out the evaluation so I can continue to improve this and other lessons.

Leave a Reply

Your email address will not be published. Required fields are marked *