From the course: Functional Programming with PHP

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Separation of data and functions

Separation of data and functions - PHP Tutorial

From the course: Functional Programming with PHP

Start my 1-month free trial

Separation of data and functions

- [Instructor] The second main concept of functional programming is the separation of data and functions. This is a case where functional programming is directly in contrast with object-oriented programming, where data and functions are almost always grouped together. So, let's see what the separation of data and functions looks like. First of all, for our purposes, data might be any values that a program contains. People's names, addresses and social security numbers in a payroll program, the models, years and colors of cars on a used car website, the positions, health levels and weapons of characters in a video game, anything. All of this is data. In object-oriented programming, this data is usually wrapped up in side objects as member variables and the only way we can access it is by using an object's methods. In functional programming on the other hand, this data is usually represented by simple arrays as we see…

Contents