note 76442 deleted from language.oop5.patterns by danbrown
| From: | danbrown@php.net | Date: | Sun, 23 Jan 2011 16:42:21 +0000 |
| Subject: | note 76442 deleted from language.oop5.patterns by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-176111@lists.php.net to get a copy of this message | ||
Note Submitter: anonymous at world4ch dot org
----
A singleton is the "enterprise professional scalable business solution" version of a
global variable. It'd be a good idea if this were the IOCCC, but since it isn't, it's
better to simply say:
global $lol;
It's also faster and more maintainable, and has the same advantages and disadvantages.
Also, I'll advise against all "enterprise object-oriented industry-standard design
patterns". Some of these patterns are correct, but their existence is not. Programming is not
about copypasta. It's about thinking, abstracting and combinating. If you can't think of
these patterns for yourself when you need them â and in the case of needing them, manage to
abstract them so that your code doesn't become a copypasta fest, then you shouldn't be
programming in the first place.
Furthermore, the existence of software patterns is a proof of the object-oriented model
shortcomings. You shouldn't ever need to do any copypasta in your code. If something is done
two or more times, you abstract it. And the language should support a way for you to. There's
no reason for a "design pattern" to exist more than once, and since they are trivial (they
better be trivial to you, if you are programming), you don't need to study them.
The best advice I can give you is that instead of reading "design patterns", you read
Structure and Interpretation of Computer Programs (SICP), a book freely available from MIT where you
will learn what you need to program properly in any programming language.