Articles with tag "patterns"
Order:   

MVC in smaller web applications

Web development is, in many cases, a process where time is a crucial factor. As coding is usually the last step in the process, all things come together and prior mistakes are revealed.
"Build this so it looks the same in all browsers, works better than the IA was ever planned and can fly." Or so we hear.
With a limited amount of time, developers are often tempted to fall for quick fixes and, not only due to last-minute changes, find themselves in a huge ball of code at the end of the project.
"What does that matter, if the site is working nicely, nobody complains and it's nodded off by the client?" I hear you ask.
This attitude is something I've encountered many times, and it usually results in a second-phase disaster, be it an extension of the site, a new face or a server change.
Comments: 159     Views: 4882     Rating: 12345



Observer pattern in PHP

I've recently pretty much fell in love with an observer design pattern. You can basically build the whole application on it using awesome power of event driven programming. What exactly is an observer pattern ? All the theory is accessible on Wikipedia. Basically we have an object you want to monitor ( observe ) for any changes. Most of the time this object just fires out events and we want to listen to them. We can have more objects observing one or more other objects so basically this can be M:N relationship. Classic example in database world are triggers. When the table is updated for example the listening trigger is fired. In window applications when the user clicks a button the event is fired and listeners are notified to handle the event. In the following example we have a validator object checking for a valid email address that fires two types of events we would like to listen to. Those types are obviously valid / invalid email address. We also implement two listeners, one for each event type, listening to the validator. The first one would just be some kind of an error logger, logging the invalid inputs and the second one would write the correct email address into database or something.
Comments: 16     Views: 8135     Rating: 12345



A caching pattern for models

This is a caching pattern for models using Zend_Cache and the __call magic method. The initial thought behind this is that a model should be able to return calls either uncached or cached, without initializing some cache object every time. It should be easy to switch between the two calls, and the cache should be coming with the model object already.
Comments: 42     Views: 8618     Rating: 12345