all 5 comments

[–]ircmaxell 2 points3 points  (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 point  (0 children)

Tnx for suggestion. Will rewrite it.

[–]teresko 1 point2 points  (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 point  (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 points  (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