Functional PHP

submited by
Style Pass
2024-10-13 05:30:02

Over the course of the past week, I had a chance to write some brand new PHP code and I took the opportunity to try writing in a (mostly) purely functional style. The experience turned out to be very pleasant and definitely helped us to accomplish our goals as we figured out the details and changes the project needed.

Like I mentioned above, modifying this (and another) program was incredibly easy. Taking the time up-front to define the interface certainly helped me to be able to make this do almost exactly what it needed to the first time I had it “finished.” Because the functions were so small, it was simple to gauge whether or not they would work as expected, then it was just a matter of stringing them together. Like a well-tested project, this one made it a breeze to find the spot of the one bug we found, preventing me from spending so much time hunting it down. The functional approach definitely lends itself well to building reasonable, effective, and comprehensive tests. It was so easy working with it at times that it kind of made me all tingly inside.

As a Code Wrangler at Automattic, Inc., I spend my days reticulating splines. As a nomad, I own very few things and enjoy living simply. I love cooking, engineering, photography, and my faithful God, Jesus Christ. View all posts by Dennis Snell

Leave a Comment