What principles should be used for PHP code with fewer objects like Java and more like functional principles of Clojure programming?

I was recently introduced to Clojure, and until I fully understood all of his concepts, he gave me an alternative to Java and PHP OO that I really want to promote. I believe Clojure systems are my ideal. I know that I want it to communicate my PHP coding style as much as possible.

I really don't like OO in PHP, I hate the number of templates and the hidden complexity this often leads to. At the same time, I see the benefits of encapsulation when you have several bits of data that carry the ability to change themselves. Perhaps the use of first-order functions is the main way to ensure this encapsulation, but beyond this, how can you take advantage of the orientation of the object in functional programming?

One of the problems I am facing right now is how to work with a set of related functions that might otherwise be grouped in a class in a reasonable way that would be useful for each of them.

+3
source share
2 answers

"97 , " " " :

http://en.wikipedia.org/wiki/Referential_transparency_(computer_science)

, OO , , - - . , , . , . , , , , , , , .

+3

, php, , ( ) , 10 , . , :

  • ,
  • stat
  • ( )

, PHP FP. "". php , .

+1

Source: https://habr.com/ru/post/1757760/


All Articles