Book reviews object-orientated programming with PhP5-ma yongzhan

Source: Internet
Author: User
Tags spl packt

Copyright statement: original works can be reproduced. During reprinting, you must mark the original publication, author information, and this statement in hyperlink form. Otherwise, legal liability will be held. Http://blog.csdn.net/mayongzhan-ma yongzhan, myz, mayongzhan

Address: http://codepoets.co.uk/book-review-object-orientated-programming-php5-hasin-hayder-packt-publishing

Suddenly I received an email from packt publishing about "Object-orientated programming with PhP5.
I have never done a book review before. I am sorry for the unreasonable structure of the comment style.

Content
In brief, the chapters in this book are:
Object-oriented (OOP) and programming (PS: should it be process-oriented) (what is oop ?, Why oop ?, Differences between the two)
Start OOP (Object (encapsulation), inheritance, polymorphism, etc)
Advanced OOP (using PHP functions, exceptions, iterations, etc)
Design Patterns (strategy, Singleton, adapter, observer, decorator etc)
Reflection and unit testing (phpunit)
Standard PHP Library (famous Spl)
Oop database (mysqli, PDO, data persistence layer runtime action layers-pear: mdb2, ADODB and active record)
OOP and XML (simplexml, XPath, DOM)
MVC/frameworks
For beginners/middle-level developers

Supported
Introduction to SPL (Standard PHP Library)
Introduction to PDO, pear: mdb2, ADODB and mysqli
The main object-oriented design modes are introduced.
Introduced MVC and frameworks (framework)

Objection
Only Page 250
In-depth
Many syntax errors are expected to be corrected during Publishing.
There are many spelling mistakes (e.g. S/Mehod ()/method ())
Some examples are poor (see below)
I will talk about the phpunit API on a ten-page basis. At the end, I will talk about developing a project using the framework. I think we should use some of the sections to share a major framework, such as Zend or codeignitor. Even so, I think this book is still good, especially to learn how to solve problems, which will be of great help to junior and intermediate developers.

Code instance
To make this book more interesting, Chapter 4 describes many major design patterns. In one decorator mode, some code 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 think it would be better to write like this:
 
$ 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 can see, this book is of excellent quality. (My feelings)
This book focuses on Object-Oriented OOP and design patterns, and covers PDO, mysqli, pear: mdb2, and other concepts as appropriate.
I think we should reduce some chapters (PDO, ADODB) to add MVC, framework, phpunit API and some examples. These contents are not deep enough-if you want to use PDO, ADODB, or get some practical experience from scratch, you are advised not to buy this book, which will disappoint you.
The ratio of text to code in this book is 50: 50. This makes people feel that the author is gathering words and filling the book with the documentation on API and php.net.
Disclaimer:-Omitted
 
 
 
 
 
 
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, role action 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 participant Area
I seemed to notice plenty of grammatical errors in the book-often missing pluralisations. i'm no grammatician, and some wocould argue in no position to lecture... but even so, somehow I have CT 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 wowould 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 flavor of the book, Chapter 4 covers varous 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 wowould have been better written:
 
$ 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 wowould 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 .....
 
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.