Skip to content

Comment on A Different Way: Traits in PHPparent

Comments

I completely agree. If Traits are something you really need, you're using the wrong language. If you need a screw driver, get a screw driver. Don't try to use the claw of a hammer. Developing with something like this will only increase the spaghetti factor. If you are a stickler for code re-use, my suggestion is to favor Composition over Inheritance.

It's also worth noting that PHP will most likely be adding Traits into the core language at some point. A patch has been available since 2008:

http://wiki.php.net/rfc/traits

Hell, if you really need traits (you don't), apply the patch. Just don't mutilate your code base.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.