Object Oriented Programming

Last reviewed 22 Feb 2020 by Crispin Read

Description

An introduction into object oriented programming design patterns.

Why this is important

Using design patterns can save time as well as help developers to create software that is easier to maintain by promoting code re-use ( Inheritance, Polymorphism, Encapsulation )

Outcomes

At the end of this training you will be able to:

  1. Create code using inheritance
  2. Navigate code to find methods being called.
  3. Decide when oop is appropriate and when it is not.

Learner Requirements

  1. A computer with a fresh PHP development environment.

Outline

  1. What is OOP
  2. The three principles of OOP.
    • Encapsulation
    • Inheritance
    • Polymorphism
  3. Loose coupling and high cohesion
  4. OOP Design patterns in PHP
    • Factory
    • Singleton (The anti pattern)
    • Strategy
  5. OOP examples in Drupal
  6. Alternatives to OOP in PHP ( OOP is not a golden bullet )

Tasks

During Training

  1. Create a class and subclass that represents person and employee.
  2. Create a module that benefits from using OOP

After Training

  1. Navigate the code inside of the Drupal core and see if you can understand what code is being executed.
  2. Fork the repo in the resources below and read through the examples.

Extra

Resources / Reference

  1. Intro Slides on Google Drive
  2. Demo on YouTube
  3. Vanilla design patterns

Skills, Knowledge, Behaviours and Values

Core Skills

This workshop is designed to develop the following from our core skills directive

  • Estimation
  • Communication
  • Teamwork

Apprenticeship Standard

This workshop will encourage the development of the following from the Software Developer Level 4 Standard

COMPETENCIES (Skills)

  • C1 - Logic: writes good quality code (logic) with sound syntax in at least one language.
  • C10 - Can apply good practice approaches according to the relevant paradigm (for example object oriented, event driven or procedural).
  • C11 - Can interpret and follow:
    • software designs and functional/technical specifications
    • company defined ‘coding standards’ or industry good practice for coding
    • testing frameworks and methodologies
    • company, team or client approaches to continuous integration, version and source control
  • C14 - Can apply the maths required to be a software developer (e.g. algorithms, logic and data structures).

BEHAVIOURS

  • B1 - Logical and creative thinking skills.
  • B2 - Analytical and problem-solving skills.

Knowledge

  • K3 - Understands how teams work effectively to produce software and contributes appropriately.
  • K4 - Understands and applies software design approaches and patterns and can interpret and implement a given design, compliant with security and maintainability requirements.