Chad Minick
Software Developer

Functional Programming

Option Pattern and avoiding Nulls pt. 3: Request Variables

In Part 1 I introduced the Option pattern as a pattern to avoid using nulls. In Part 2 I showed an example of how this can be handy in method chaining. In this part I'll introduce how to use Option for request variables.

Read More ...

Option Pattern and avoiding Nulls pt. 2: Method Chaining

In Pt. 1. I introduced Option as a way to avoid running into problems using null. Now to show you one of those problems. Consider the following method:

function isPass($student, $course) {
  $grade = StudentRegistry::getStudent($student)->getCourse($course)->getGrade();
  if($grade > 60) {
    return true;
  }
  return false;
}
Read More ...

Option Pattern and avoiding Nulls pt. 1: Introduction

I imagine in the PHP community, the idea of avoiding nulls in your code might be something new to think about. Because PHP is a dynamically typed language, nulls are handled much better compared to other languages. However, they do still cause a lot of issues. Two of the main places I see issues with nulls in PHP is method chaining and request variables. I'll make two more parts to this series to cover each. This is part 1: introduction to the Option pattern.

Read More ...
Chad Minick | Software Developer
Twitter | Github | LinkedIn