Monday, 26. November 2007, 07:44:56
design patterns, programming
A lot of people seem to be slightly confused about what the M and C, Model and Controller, of MVC are, in regards to web applications.
- What does the Model do?
- What does the Controller do?
View is what everyone seems to know, though… I wonder why is that so? What is so confusing about Models and Controllers?
Read the rest of the post at codeutopia.net
Monday, 17. September 2007, 09:13:19
design patterns, programming
Why use
Singleton over Static classes?
If you want a simple class that's accessible from everywhere in your code, you could easily use a static class to achieve this.
In PHP, you can use :: to access classes statically: MyClass::doSomething(), in C# you can declare a class static and so on. It's much simpler to create and access static classes than singleton classes, too.
The singleton does have some advantages though...
Read more...
Thursday, 30. August 2007, 05:16:17
PHP, design patterns, programming
Globals are evil - do not use them. Quoting
Martin Fowler,
remember that any global data is always guilty until proven innocent.
What is a global? A global is a variable that is accessible from anywhere in an application. For example, in PHP declaring any variable outside a function/class method will make it global.
But what about when I want to have some data globally available in my application?
One useful solution is to use the singleton pattern to create a storage class or something like that. We'll look at that later in this post.
Read more...
Friday, 10. August 2007, 15:04:57
design patterns, PHP, source code
In my
post about the problems in Zend Framework implementation of the MVC pattern I briefly mentioned the factory design pattern and that it could be used to create a view factory.
In this post I'll explain the concept of the factory a bit further and provide an example view factory implementation for you. We also brush the singleton pattern a bit.
Read more...