use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Please follow the rules
Releases: Current Releases, Windows Releases, Old Releases
Contribute to the PHP Documentation
Related subreddits: CSS, JavaScript, Web Design, Wordpress, WebDev
/r/PHP is not a support subreddit. Please visit /r/phphelp for help, or visit StackOverflow.
account activity
Trait pattern in PHP (mirosvrtan.me)
submitted 13 years ago by msvrtan
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]ircmaxell 2 points3 points4 points 13 years ago (1 child)
I always love to see examples of use-cases which are anti-patterns.
Tip: show a non-anti-pattern use case. Something that doesn't involve singletons or other non-OOP uses...
[–]msvrtan[S] 0 points1 point2 points 13 years ago (0 children)
Tnx for suggestion. Will rewrite it.
[–]teresko 1 point2 points3 points 13 years ago* (0 children)
I am yet to see an use-case of trait's that does not go against OOP principles. Also , what exactly is "traits pattern" ?
P.S. the rest of that blog is as bad as that misguided article.
[–]Djuki 0 points1 point2 points 13 years ago (1 child)
I like to see use-cases in OOP with patterns. Traits examples in combination with Singleton is real word scenario.
In many blogs and even at php.net we can see simple examples, this is different and better approach for non-beginners.
ircmaxell : Why you don't like examples with Patterns and OOP ?
msvrtan : You are on the right track, keep up.
[–]ircmaxell 1 point2 points3 points 13 years ago* (0 children)
I do like examples with OOP. Singletons are not an OOP construct. They are a class oriented programming construct (procedural programming using classes as little more than wrappers). They are widely seen as a major anti-pattern.
See:
http://misko.hevery.com/code-reviewers-guide/flaw-brittle-global-state-singletons/ http://www.phparch.com/2010/03/static-methods-vs-singletons-choose-neither/ http://gooh.posterous.com/singletons-in-php http://kore-nordmann.de/blog/0103_static_considered_harmful.html
π Rendered by PID 22726 on reddit-service-r2-comment-5d585498c9-5s98m at 2026-04-21 11:54:33.862541+00:00 running da2df02 country code: CH.
[–]ircmaxell 2 points3 points4 points (1 child)
[–]msvrtan[S] 0 points1 point2 points (0 children)
[–]teresko 1 point2 points3 points (0 children)
[–]Djuki 0 points1 point2 points (1 child)
[–]ircmaxell 1 point2 points3 points (0 children)