views:

93

answers:

1

$Zend_auth->authenticate($adapter);

Why is it called an adapter and not a strategy?

+7  A: 

Good question koen. I'd agree that the Zend_Auth_Adapter component is a good representation of the Strategy pattern. An argument could be made that it is a candidate for the Adapter pattern as well. It is serving as an adapter to whatever authentication mechanism you are using, which could be another class (making this more obviously an Adapter), but even for something such as authentication using credentials stored in a database it is serving as a plain-english adapter to your underlying credential store.

Also, there is no convention in the Zend Framework to call each class by it's pattern name. There are no Xxx_Singleton, Xxx_Strategy, or Xxx_Builder classes despite there being classes that fit these patterns. Yet, at the same time there are Xxx_Decorator classes.

Most importantly, from it's earliest days as a proposal it was referred to as an Adapter. The ZF community accepted this, and noone objected to it's naming. Thus, it was adopted into the framework and will likely forever be known as Zend_Auth_Adapter.

hobodave
I think it makes sense to have a "db adapter", "ldap adapter" vs. "db strategy", "ldap strategy" (or whatever). It sounds much more understandable =)
Jani Hartikainen
zomg! Yes, plain english ftw.
hobodave
I don't find one is more understandable than the other.
koen