2009年8月28日星期五

[fw-db] A question on coding design used for DB Statements.

I'm almost done reading the code that covers all the Zend_Db classes. One
part that intrigues me is why _prepare() from Zend_Db_Statement is not
declared as an abstract method. I probably didn't catch something from the
code, and I'm not an expert in software design and architecture, but I'm
interested into software architecture (been reading some books lately).

What I notice is the following: the constructor of Zend_Db_Statement calls
for "$this->_prepare($sql)", which is never declared in that class.
Zend_Db_Statement doesn't inherit from anyone and only implements the
interface Zend_Db_Statement_Interface, which does no mention of a _prepare
method. So, the call in the constructor is always there, meaning that the
method MUST be implemented, but there's no enforcing of it. I can see that
extending classes (the one that I checked the most was
Zend_Db_Statement_Pdo) do implement the method.

So, I wonder why _prepare is not declared in Zend_Db_Statement as "abstract
protected function _prepare($sql);".

Reading all the code from the framework has been a very productive activity
so far =) I'm really thankful for the developers (I've no idea where they
are hehehe), not only for the good quality code, but also for the great
documentation.

Now, off to finish Zend_Db and moving to Zend_View, Zend_Controller and
Zend_Validate.

And this is just a guy that wants to learn more about programming in PHP.
I'm not trying to point out mistakes or to feel smart, but to learn about
decisions made by professional developers. Sometimes people that questions
things or makes critics do it for the wrong reasons, I just don't want to
look like someone like that.

Thanks in advance for responses.
--
View this message in context: http://www.nabble.com/A-question-on-coding-design-used-for-DB-Statements.-tp25193487p25193487.html
Sent from the Zend DB mailing list archive at Nabble.com.

没有评论: