One of the worst examples I've seen is the functional programming paradigm being crowbarred out of PHP .. why.
One of the worst examples I've seen is the functional programming paradigm being crowbarred out of PHP .. why.
Most likely related to the Innter-platform effect: ...the tendency of software architects to create a system so customizable as to become a replica, and often a poor replica, of the software development platform they are using.
http://en.wikipedia.org/wiki/Inner-platform_effect
One of the classic PHP examples being the Smarty templating system:
Smarty has been criticized for replicating features that PHP does natively very well, which leads to inefficiency:
PHP still sucks though ;)
It's not perfect, but it's better than what we had before.
// Create a message
$message = Swift_Message::newInstance('Wonderful Subject')
->setFrom(array('john@doe.com' => 'John Doe'))
->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name'))
->setBody('Here is the message itself')
;It's useful in some instances, and is a bit different than currying because PHP doesn't really support proper currying.
The stateless way would be to return an entirely new Swift_Message instance with each setX method. In languages that aren't built with immutability in mind, like PHP and Java, you end up instantiating and throwing away a lot of objects. Sometimes it doesn't matter, but when it does you use a mutable Builder to create the immutable instances.
That's why I said it appears to try and avoid state. Either way, as far as I'm concerned it's an horrific way to write code in an imperative language such as PHP.
setX is reminicent of Java to me, and of small talk attribute setters/getters before it.
Both of those languages elevate state to the point of godhood.