decoration decoration
Stories

GROKLAW
When you want to know more...
decoration
For layout only
Home
Archives
Site Map
Search
About Groklaw
Awards
Legal Research
Timelines
ApplevSamsung
ApplevSamsung p.2
ArchiveExplorer
Autozone
Bilski
Cases
Cast: Lawyers
Comes v. MS
Contracts/Documents
Courts
DRM
Gordon v MS
GPL
Grokdoc
HTML How To
IPI v RH
IV v. Google
Legal Docs
Lodsys
MS Litigations
MSvB&N
News Picks
Novell v. MS
Novell-MS Deal
ODF/OOXML
OOXML Appeals
OraclevGoogle
Patents
ProjectMonterey
Psystar
Quote Database
Red Hat v SCO
Salus Book
SCEA v Hotz
SCO Appeals
SCO Bankruptcy
SCO Financials
SCO Overview
SCO v IBM
SCO v Novell
SCO:Soup2Nuts
SCOsource
Sean Daly
Software Patents
Switch to Linux
Transcripts
Unix Books

Gear

Groklaw Gear

Click here to send an email to the editor of this weblog.


You won't find me on Facebook


Donate

Donate Paypal


No Legal Advice

The information on Groklaw is not intended to constitute legal advice. While Mark is a lawyer and he has asked other lawyers and law students to contribute articles, all of these articles are offered to help educate, not to provide specific legal advice. They are not your lawyers.

Here's Groklaw's comments policy.


What's New

STORIES
No new stories

COMMENTS last 48 hrs
No new comments


Sponsors

Hosting:
hosted by ibiblio

On servers donated to ibiblio by AMD.

Webmaster
Book Review: Peter Lavin's "Object-oriented PHP" - reviewed by Azrael
Saturday, October 21 2006 @ 12:38 AM EDT

Here's another book review for you. Our own Azrael volunteered to review Peter Lavin's "Object-oriented PHP," published by No Starch Press, and here it is. The publisher's blurb reads, in part:
If you are a PHP programmer who wants to make the switch to an object-oriented approach, Object-Oriented PHP can ease the transition from procedural to object-oriented programming. Basic concepts are introduced using simple but useful classes. By the time you've finished this book you'll have an excellent grasp of object-oriented programming and numerous classes that can be easily reused in a variety of circumstances. But, more importantly, you'll be able to create your own classes and extend existing ones.

I asked Azrael what biographical information, if any, he'd care to share, and here is his reply:

Azrael is happy to be known as a computing science graduate working at one of the world's (recently voted) top 10 Universities - if only because while being absolutely true, it makes him sound far more interesting than he really is. His interests tend towards the technical and geeky, and in recent years he has been responsible for all too much sloppy PHP code being released into the wild. He thought it was about time he read a book on PHP.

The book is also available from Amazon US or Amazon UK and Barnes and Noble, as well as from No Starch Press -- as a book or a PDF -- and you can read chapter 8, Using the PageNavigator Class as a PDF download. No Starch also makes the code examples available for download. Enjoy, everyone!

*****************************

"Object-oriented PHP," by Peter Lavin - reviewed by Groklaw's Azrael

A few months ago a package came through the letter box, bringing excitement into my life. I received a copy of "Object-oriented PHP," published by No Starch Press to review. This is the first time I've received a book to review, and my excitement was such that I was at once looking forward to writing something glowing with praise. My immediate excitement has died down over the time since I received it, and having now read it I feel able to objectively write a review. Any praise which glows does so genuinely and not out of any any initial ebullience.

Lifting from the back cover of the book "Peter Lavin runs a web development firm [...] has been published in a number of magazines [... and] is a contributor to PHP Hacks (O'Reilly)"...

The books is aimed at PHP developers without much object-oriented experience, and at object-oriented programmers wanting to learn PHP.

I come to the book having taught myself PHP a little over 3 years, and having studied object-oriented programming at University about four years ago. I regard myself as still learning PHP, picking up the bits I need to know as and when necessary, and I haven't done all that much object-oriented programming in the past four years. I'm quite sure this makes me almost the ideal audience for this book.

My initial perception of the book is that it is well-written, and immediately engages the reader with practical and clearly explained examples. Code is provided that will give the author an immediate 'win' in adding certain common functionality to their site.

Chapter one starts with a quick overview of object-oriented programming, giving the arguments for and against, and ultimately coming down on the side that every additional tool that might make the programmer's job easier is well worth learning and that the author is free to decide for themselves what to use.

Chapter two gives a quick introduction to the concepts of object-oriented programming, touching ever so briefly on reuse and forms of inheritance. Being quite comfortable with the concepts of OOP I found this chapter (all four pages of it) a nice refresher. Anyone new to OOP might be left feeling as if they are being dropped in the deep end, wanting more information to fully grasp OOP concepts before continuing. However, later chapters do not assume too much from the reader, and when OOP concepts are raised, they are done so with further explanations. An insecure reader should press on, confident that they are not expected to grasp the intricacies of OOP from this chapter alone.

Chapter three takes a look at the object-oriented features of PHP5 as compared with PHP4. Anyone confident with PHP4 should find this chapter useful. In contrast with chapter two, old-hands at PHP should fly over this chapter comfortably while the confident object-oriented programmer new to PHP may find the comparisons between the versions of PHP non-relevant.

With chapters four to ten, the overviews and principles are behind us, and we start meeting solid code examples of how to get things done. Example code is immediately useful, and from chapter to chapter the code builds up in functionality. In addition to leading the reader slowly through the increasingly effective example code, I felt the benefits of the object-oriented approach are subtly demonstrated. As a fan of OOP I felt as if this was exactly what someone new to OOP needs to see: the increasing complexity of the code pushed into classes, while remaining easy to call upon and use.

Chapter eleven introduces more advanced OOP concepts and techniques which from my own perspective are easily understood. Someone new to OOP might find the easy and gentle approach to the theory a little too hands-off which might have a negative impact upon thorough understanding.

Chapters twelve to sixteen give a cursory introduction to things like simpleXML, RSS, the Google API, AJAX, SOAP, magic methods, reflection, extending SQLite, and PHP Data Objects. Just enough detail is given to whet the appetite, but anyone interested in these areas would be well advised to get a more advanced PHP book.

For those less concerned with understanding OOP in the abstract and just interested in getting on with using OO-PHP and getting stuff done, I think this book hits the right tone. This book certainly lives up to the subtitle of: Concepts, techniques, and code. If you are part of the target audience for this book, I think you will find it of great value, and I can fully recommend it.

This is the first book I've ever read on PHP, so I can't compare it to other books. However, while the book is easy to read, if I was new to PHP and didn't have a grasp on OOP, I'm not sure this book would have worked well for me. If the most damning thing I can say about the book is that it doesn't work well for those it isn't targetted to, then it is clear that this book gets a double thumbs-up from me.

While I was working on this review, I noticed another helpful review this book on OSNews, if you want to see what someone else thought. It is well worth a look.


  


Book Review: Peter Lavin's "Object-oriented PHP" - reviewed by Azrael | 145 comments | Create New Account
Comments belong to whoever posts them. Please notify us of inappropriate comments.
relevance?
Authored by: Anonymous on Saturday, October 21 2006 @ 01:57 AM EDT
I'm not trying to be a troll. I am not trying to criticize anyone. I am not
anonymous to hide my identity - I just never saw the need to create an account.
End of disclaimers.

Now, that said, how's a PHP book review relevant enough to warrant posting on
groklaw? Yes, I realize that groklaw is, in a way, PJ's blog, so she can post
whatever she pleases... but still... It's a review of a book on the basics of a
programming language. The language happens to be open source (although not our
beloved GPL), but that feeble link aside, how's it relevant to law, and what we
have come to expect to see on groklaw?

I have nothing against PHP -- I've used it and I have contributed a few bits of
code to the php codebase over the years. I was just wondering how this review
ended up on groklaw.

[ Reply to This | # ]

Corrections here, please
Authored by: ankylosaurus on Saturday, October 21 2006 @ 01:59 AM EDT
"actually is" --> "should be" in the title works quite
nicely.

---
The Dinosaur with a Club at the End of its Tail

[ Reply to This | # ]

Off topic
Authored by: ankylosaurus on Saturday, October 21 2006 @ 02:03 AM EDT
Please make links clickable.

The discussion of whether this review belongs on Groklaw is not off-topic, and
should be discussed under one of the other threads.

---
The Dinosaur with a Club at the End of its Tail

[ Reply to This | # ]

PHP & OO
Authored by: Quila on Saturday, October 21 2006 @ 09:41 AM EDT
I'm a PHP developer since the 90s, and I do like the language, especially the
integration with MySQL (also a long-term favorite for light jobs, until 5 gave
enterprise features). But OO really does seem tacked-on to PHP, just as it was
tacked-on to Microsoft's Visual Basic. Even Microsoft's C# does it better, since
it has the advantage of being written from scratch for OO.

[ Reply to This | # ]

Another perspective on the book
Authored by: Anonymous on Sunday, October 22 2006 @ 05:47 AM EDT

First, I'd like to say thanks for taking the time to write this and share it with everyone. Seemed a bit of a non-sequitur after the recent escalation in the SCO vs Everyone Else's Software conflict, but no complaints there, content is better than no content after all!

I'd like to respectfully disagree with the "double thumbs up" on this review. I recently read the book and found it lacking in several areas. Unfortunately, although I'd like to recommend an alternative, I haven't come across one yet that matches the concise clarity of the php.net reference documentation. The "Dummies" series comes close, but not quite close enough IMHO.

To start with, the publisher seems to be aiming at people who use PHP but are unaware of OO techniques:

By the time you've finished this book you'll have an excellent grasp of object-oriented programming...

however the review clearly points out

Anyone new to OOP might be left feeling as if they are being dropped in the deep end

... a point with which I would agree. So surely this means that the book doesn't hit the target audience?! Yes, several parts of the OO approach are covered further on in the book, as indicated by the review, but not in enough detail to truly convey why those techniques are so useful. More examples and more focus on OO would be far better IMHO than the scattered and superficial survey of APIs and the PHP libraries.

Building up code through the book would help - as it is, there's a PageNavigator class which is half-heartedly tweaked, but never grows to a size that really shows off the benefits of OO techniques. Something more complete, such as a simple templating hierarchy, would be a good opportunity to put the concepts into practise.

Design patterns aren't really covered, although they are briefly looked at and used in some of the examples - a singleton database class works very well with MySQL, for example, allowing any code which needs a database connection to open or reuse the existing connection... yet the provided example expects a connect() and only uses the static variable to report an error!

Here's another example - the book is about OO programming with PHP5, yet when dealing with MySQL, it uses the old procedural mysql extension, rather than mysqli. Although the newer extension isn't available everywhere, if you have PHP5, it's more than likely mysqli is available too.

Some other areas which are almost essential in using the PHP OO model to its full extent are conspicuous by their absence. The __autoload function, for example - it allows classes to be loaded without requiring explicit include (require_once) directives. Very useful. Didn't get used once in the examples, and I don't recall seeing it in the book text. More examples using magic methods would help, too.

In fact, you can get an idea of how extensively OO techniques are used by downloading the example source files - "extends", the principle keyword for implementing inheritance, is used a total of 5 times across all the examples! "implements" is used twice. There isn't a single abstract base class in the entire book. It's really not a case of practising what the author preaches.

One final, but this time comparatively minor nitpick is that the examples were badly formatted, almost completely free of comments (magic numbers like 5000 used directly, rather than as const / define values, without any explanation). The style of coding leaves plenty of scope for errors to creep in, definitely not a book to rely on for best practises and overall quality of code.

[ Reply to This | # ]

  • Example chapter - Authored by: Anonymous on Sunday, October 22 2006 @ 06:02 AM EDT
Please just let PHP die
Authored by: imroy on Sunday, October 22 2006 @ 08:31 AM EDT
If you really are "a PHP programmer who wants to make the switch to an object-oriented approach", you'd do better by switching to a proper language like Python, Perl, or Ruby. PHP is a disgusting language, composed of hacks built upon workarounds built upon an unorganised mess. And the world has moved on from the practice of embedding HTML in code, embedded in HTML. Learn a better language, find a proper templating toolkit (or better yet, an MVC framework with templates), and free yourself from the cognitive load of remembering all the inconsistent junk in PHP.

[ Reply to This | # ]

Groklaw © Copyright 2003-2013 Pamela Jones.
All trademarks and copyrights on this page are owned by their respective owners.
Comments are owned by the individual posters.

PJ's articles are licensed under a Creative Commons License. ( Details )