 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
DevArticles.com: Singletons in PHP
by Chris Cornutt December 06, 2011 @ 10:17:33
On DevArticles.com today there's a new tutorial posted talking about one of the more popular design patterns, the Singleton, and how it can be implemented in PHP.
Though in the past they enjoyed both popularity and a certain amount of prestige, without a doubt Singletons have progressively become one of the most evil and despicable villains in object-oriented design. Singletons earned their bad reputation for a reason: bringing them to life requires the programmer to deal at least with a static method. This is simply an elegant masquerade for creating a global access point (which in most cases is mutable as well) throughout an entire application. And we all know that global, mutable access is unquestionably a bad thing that must be avoided at all costs.
In this first part (of two) of the series they introduce the Singleton pattern and show how, via an example of using a database adapter interface to work with a MySQL database, in a tightly coupled example.
In the second part of the series, they'll show how to break these apart using dependency injection.
voice your opinion now!
singleton designpattern dependencyinjection di mysql database adapter interface
Zend Developer Zone: My Favorite Design Patterns
by Chris Cornutt April 25, 2011 @ 10:38:13
On the Zend Developer Zone there's a new article from Keith Casey where he talks about some of his favorite design patterns he's come across in his time as a developer - adapter, facade and decorator.
Within the Design Patterns world, there are four main categories: Architectural, Structural, Creational, and Behavioral. Architectural patterns describe the system as a whole, Structural patterns describe the relationships between objects, Creational handle creating objects, and finally Behavioral describe the communication patterns between objects. Each of the categories is worth discussion on its own, but in this case we'll stick to the Structural patterns of Adapter, Facade, and Decorator.
He describes each of the patterns (no code in this one, just descriptions) and for each mentions some of the tools that the Zend Framework has to offer that match up. For example, the Adapter pattern is used in quite a few places in the framework including in the Zend_Db component for the connection types to different databases.
voice your opinion now!
designpattern zendframework adapter facade decorator
Daniel Cousineau's Blog: Doctrine 1.2 MSSQL Alternative LIMIT/Paging
by Chris Cornutt September 17, 2010 @ 11:34:03
Daniel Cousineau has a new post to his blog today looking at an alternative that can be used for pagination in your MSSQL queries than the trick with TOP and reversing the ORDER BY in Doctrine.
As ugly as this technique is, it works. The problem is it requires an extreme amount of intelligence or an extreme amount of simplicity in the query in order for an automated system like Doctrine to be usable. The biggest caveat with this technique is good goddamned luck paging your query if it doesn't have an ORDER BY. And sometimes queries that are complex enough break the modified Zend_Db code. There exists an easier MSSQL paging technique. Using features first available in SQL Server 2005, with only 1 subquery you can mimic MySQL's LIMIT clause with ease.
He includes the query that will make it happen (the SQL for it) and then the implementation as an adapter you can use to get it to cooperate in your Doctrine queries.
voice your opinion now!
mssql doctrine limit paging adapter
NETTUTS.com: A Beginner's Guide to Design Patterns
by Chris Cornutt July 08, 2010 @ 08:47:55
On NETTUTS.com today there's a new tutorial that introduces a bit more advanced concept in the development process - design patterns.
Design patterns are optimized, reusable solutions to the programming problems that we encounter every day. A design pattern is not a class or a library that we can simply plug into our system; it's much more than that. It is a template that has to be implemented in the correct situation. It's not language-specific either. A good design pattern should be implementable in most - if not all - languages, depending on the capabilities of the language.
They introduce a few of the more widely used patterns including the strategy pattern, adapter pattern, factory methods, decorator and singleton patterns. Each comes with a bit of code showing how it would work and a "where would I use this?" section with a better example.
voice your opinion now!
designpattern beginner strategy factory singleton decorator adapter
Richard Thomas' Blog: Solar Framework Shorts - Using Multiple auth adapters
by Chris Cornutt April 07, 2010 @ 15:56:30
Richard Thomas has posted another "Solar Short" to his PHPJack blog today dealing with a method for using multiple authentication methods in a single Solar framework installation.
What if you want to use multiple methods? OpenID? Facebook Connect? Saml? or one of the other dozen+ solutions that you might use.. What to do? One thing to keep in mind, Auth happens really early in the bootstrapping process so things like SQL may not be available yet unless you specifically loaded it in the config.. Then you need to load the proper auth module and call it as needed..
He includes a code example of how it would work - extending the Solar_Auth_Adapter to create a single "multi-adapter" with a switch to evaluate and load/use the correct authentication method. It uses the Solar_Config object to set the Auth Adapter when it's loaded so you can even use multiples in the same page load if you need it.
voice your opinion now!
solar framework multiple authentication adapter tutorial
Richard Thomas' Blog: Solar Framework Shorts - Creating your own OpenID Auth Adapter
by Chris Cornutt December 21, 2009 @ 10:09:01
Richard Thomas has posted another Solar framework short today. This time it's about OpenID and how you cn easily create a custom adapter that integrates directly into the framework to support it.
Solar makes heavy use of Adapter based classes, Solar_Auth is one of these. This makes adding additional methods pretty easy and allows you to borrow from other Frameworks without having to Hack in a third party auth setup, You can use the basics provided by Solar.
He includes a code example showing how to extend the Solar_Auth_Adapter component to create an OpenID adapter you can use as a part of your authentication process. His Solar component encourages code reuse too by using the Zend Framework native OpenID implementation as its authetication functionality.
voice your opinion now!
solar framework openid authentication adapter
Federico Cargnelutti's Blog: Database Replication Adapter for Zend Framework Applications
by Chris Cornutt October 05, 2009 @ 09:33:00
Federico Cargnelutti has added a new post to his blog today looking at a database replication adapter he's created for the Zend Framework - the ReplicationAdapter.
In 2008, Paul M. Jones announced the release of an SQL adapter that allows Solar users to connect to master/slave database installations. My first reaction was: Great! This will inspire other FOSS developers to create similar components. And guess what, it did. I wrote my own ReplicationAdapter. It's not great, but it's flexible enough to support the most commonly used replication scenarios:
He gives examples of how it can be used for single-master replication, multi-master replication and how the adapter can be used to create a distributed caching system for database connections. A brief Zend Framework-based example is also included.
voice your opinion now!
database replication adapter zendframework
|
Community Events
Don't see your event here? Let us know!
|