版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章原始出版、作者信息和本声明。否则将追究法律责任。http://blog.csdn.net/mayongzhan - 马永占,myz,mayongzhan
原文地址:http://codepoets.co.uk/book-review-object-orientated-programming-php5-hasin-hayder-packt-publishing
突然接到Packt publishing的邮件,内容是关于”Object-Orientated Programming with PHP5“的书评。
以前从来没有做过书评,对于评论的样式内容结构的不合理,在此对读者表示歉意。
内容
简要概述,这本书的章节是:
面向对象(OOP)与程序设计(PS:应该是面向过程吧)(什么是OOP?,为什么要OOP?, 两者的区别等等)
开始 OOP (对象(封装),继承,多态等等)
高级OOP (使用 PHP 函数,异常,迭代等等)
设计模式Design Patterns (Strategy, Singleton, Adapter, Observer, Decorator etc)(这里就不译了)
反射和单元测试(phpUnit)
Standard PHP Library (著名的SPL)
OOP数据库 (MySQLi, PDO, 数据持久层Abstraction layers - PEAR::MDB2, ADODB and Active Record)
OOP和XML (SimpleXML, xpath, Dom)
MVC / Frameworks
针对初/中水平开发人员
支持
适当的介绍了 SPL (Standard PHP Library)
介绍了 PDO, PEAR::MDB2, AdoDB and MySQLi
介绍了主要的面向对象设计模式
介绍了MVC和frameworks(框架)
反对
只有250页
不够深入
很多语法错误,希望在出版的时候能够改正这些错误。
有很多拼写错误 (e.g. s/Mehod()/Method())
有些例子很差(请见下文)
十页的篇幅去讲PHPUnit API,在最后讲使用框架开发一个项目,我觉得应该利用一部分篇幅将一个主要的框架,例如zend或者codeignitor。话虽如此,我觉得这本书还是不错的,尤其是能学到别人怎么解决问题,这对于初中级开发人员会有很大的帮助。
代码实例
为了使这本书更有意思,第四章讲了很多主要的设计模式。其中一个decorator模式,部分代码如下:
$post = new Post();
$comment = new Comment();
$post->filter();
$comment->filter();
if($BBCodeEnabled==false && $EmoticonEnabled==false) {
$PostContent = $post->getContent();
$CommentContent = $comment->getContent();
}
elseif($BBCodeEnabled==true && $EmoticonEnabled==false) {
$bb = new BBCodeParser($post);
$PostContent = $bb->getContent();
$bb = new BBCodeParser($comment);
$CommentContent = $bb->getContent();
}
elseif($BBCodeEnabled==false && $EmoticonEnabled==true){
$em = new EmoticonParser($post);
// etc.
}我觉得这样写会更好:
$post = new Post();
$post->filter();
$comment = new Comment();
$comment->filter();
if($BBCodeEnabled==true) {
$post = new BBCodeParser($post);
$comment = new BBCodeParser($comment);
}
if($EmoticonEnabled==true){
$post = new EmoticonParser($post);
$comment = new EmoticonParser($comment);
}
$PostContent = $post->getContent();
$CommentContent = $comment->getContent();But I digress....
概要
正如你所看到的,这本书是我看过的书中质量非常好的。(这段作者的感慨)
这本书围绕着面向对象OOP和设计模式Design Patterns,适当的涵盖PDO, MySQLi 或PEAR::MDB2等概念。
我认为应该减少一些章节(PDO,ADODB)来增加 MVC,框架framework, PHPUnit API 和一些例子。这些内容本身深度不够 - 所以如果你想从零开始使用PDO,ADODB或者想要得到些实际的经验,那么建议还是不要买此书,这会让你失望的。
这本书文字和代码的比例是50:50。这有点让人感觉到作者是在凑字,是在用API和php.net上的文档来填充这本书。
免责声明: - 略
Book Review: Object-Orientated Programming with PHP5 (Hasin Hayder, Packt Publishing) - David Goodwin
After an email out of the blue from someone at Packt publishing, here's a review of "Object-Orientated Programming with PHP5"
I don't think I've done a book review before, so apologies in advance if it's not structured in any logical manner.
Contents
Briefly summarised, the book's chapters are :
OOP vs Procedural Programming (what is OOP?, why?, differences between etc)
Kick Starting OOP (objects, inheritance, polymorphism etc)
More OOP (useful PHP functions, exceptions, iterators etc)
Design Patterns (Strategy, Singleton, Adapter, Observer, Decorator etc)
Reflection and Unit Testing (phpUnit)
Standard PHP Library
Databases in an OOP way (MySQLi, PDO, Abstraction layers - PEAR::MDB2, ADODB and Active Record)
Cooking XML with OOP (SimpleXML, xpath, Dom)
MVC / Frameworks
It's aimed at beginner/intermediate programmers
Pros
Introduces SPL (Standard PHP Library) in reasonable depth
Introduces PDO, PEAR::MDB2, AdoDB and MySQLi
Introduces the main OO patterns
Introduces MVC and frameworks
Cons
It's only 250 pages
It doesn't go into much depth in any particular area
I seemed to notice plenty of grammatical errors in the book - often missing pluralisations. I'm no grammatician, and some would argue in no position to lecture... but even so, somehow I expect published books to be near perfect.
There were occasional spelling mistakes in the code (e.g. s/Mehod()/Method())
Some of the example code was poorly presented/written (see below for example)
10 pages are spent providing the PHPUnit API, and the last chapter focuses on what I assume is the author's home made framework. I feel the pages would have been better spent covering one of the main frameworks (e.g. Zend or CodeIgnitor). Having said that, I found it vaguely interesting to see how someone else had tackled the problem - but I doubt the book's target market of beginners/intermediate programmers will.
Random Code Example
To give a better flavour of the book, chapter 4 covers various software patterns. One of which is the decorator pattern. Part of the example shown is as follows :
$post = new Post();
$comment = new Comment();
$post->filter();
$comment->filter();
if($BBCodeEnabled==false && $EmoticonEnabled==false) {
$PostContent = $post->getContent();
$CommentContent = $comment->getContent();
}
elseif($BBCodeEnabled==true && $EmoticonEnabled==false) {
$bb = new BBCodeParser($post);
$PostContent = $bb->getContent();
$bb = new BBCodeParser($comment);
$CommentContent = $bb->getContent();
}
elseif($BBCodeEnabled==false && $EmoticonEnabled==true){
$em = new EmoticonParser($post);
// etc.
}
I feel this would have been better written as :
$post = new Post();
$post->filter();
$comment = new Comment();
$comment->filter();
if($BBCodeEnabled==true) {
$post = new BBCodeParser($post);
$comment = new BBCodeParser($comment);
}
if($EmoticonEnabled==true){
$post = new EmoticonParser($post);
$comment = new EmoticonParser($comment);
}
$PostContent = $post->getContent();
$CommentContent = $comment->getContent();
But I digress....
Summary
As you might see, I have slightly mixed feelings about the book. I think it grew on me as I read more of it, and some of my initial negativity wore off over time.
The book does provide a good grounding in OOP and Software Design Patterns. However, it doesn't really go into enough detail when it covers PDO, MySQLi or PEAR::MDB2 for it to be a usable self contained resource.
I think it would have been better for the book to drop the section on the home grown MVC framework, and the PHPUnit API and expand some of the examples. It doesn't cover what it does in enough depth on it's own - so don't buy it if you're looking to gain a working knowledge of something it covers (e.g. PDO, AdoDB or the like) from scratch.
The book does maintain something like a 50:50 ratio between code and text. At times this does make it feel a little like the author is padding the book with code, and duplicating the API at php.net for no real reason.
Disclaimer - I got the book for free, as long as I published a review.....
分享到:
相关推荐
Axel-Tobias Schreiner,"Object-Orientated Programming with ANSI-C" Publisher: Hanser Fachbuch | ISBN: 3446174265 edition December 1, 1994 | PDF | 252 pages
一对象编程使用Python进行面向对象编程的初学者指南。 在GitHub中打开objectorientatedprogramming.ipynb或下载文件夹,然后在JupyterLab中打开objectorientatedprogramming.ipynb。
面向对象PHP-HTML-Page使用PHP保证100%HTML / XHTML兼容输出的一组类。 只需设置HTML结构并选择HTML / XHTML版本进行输出即可。 !!!注意:需要PHP 5才能运行!!!
一个基于oo的免费c ++ 2d引擎
NULL 博文链接:https://oojdon.iteye.com/blog/905787
Some of the major additions to C include object-orientated programming, operator overloading, multiple inheritance and exception handling. The development of C++ began in 1979, seven years after C ...
Recognize various JavaScript design patterns and learn the basics of JavaScript object-orientated programming Implement the latest ECMAScript 6 for client-side scripting in your web applications ...
20 rules for object orientated programming
* Comprehensive guide to using JADE to build multi-agent systems and agent orientated programming. * Describes and explains ontologies and content language, interaction protocols and complex ...
illustrated with examplesTake a deep dive into CSS properties and functions and master their usageFind clear, concise descriptions of JavaScript syntax and expressionsRecognize various JavaScript ...
The purpose of this book is to provide tools to design and implement network-orientated applications in .NET. It is also a guide for software designers to choose the best and most efficient way to ...
You will then learn the advanced Swift programming concepts, including memory management, generics, protocol orientated and functional programming and with this knowledge you will be able to tackle ...
oriented controlled three-phase AC drive as well as of a grid voltage orientated controlled wind power plant the inverter control by space vector modulation is extensively discussed with the help of ...
Specifically, curve-orientated text is largely out-numbered by horizontal and multi-oriented text, hence, it has received minimal attention from the community so far. Motivated by this phenomenon, we...
The highly c-orientated (002) hexagonal and smooth Ti film, whose mean grain size and root mean square roughness are approximately 250 nmand 1.54 nmrespectively, is realized with Ts of 300 °C and Rd...
This book is designed to help you prepare for your Zend Certification and addresses the core ...Object Orientated PHP Security Data Formats and Types Input-Output (I/O) Web Features Databases and SQL
STAL,一种小型且面向堆栈的语言,与Forth有很多相似之处,但又有所不同!!
核心玩家世界一个Player -orientated World只包括Tile S中的Player已经看到,并返回UndiscoveredTile小号否则。
5.6 General antenna coupling formula: arbitrarily orientated antennas 143 5.7 Plane-polar and plane-bipolar near-field to far-field transform 148 5.7.1 Boundary values known in plane-polar coordinates...
STOMP(Simple Text Orientated Messaging Protocol)全称为简单文本定向消息协议,它允许STOMP客户端与任意STOMP消息代理(Broker)进行交互。Spring框架中的spring-messaging模块提供了一种基于WebSocket的STOMP...