on February 18, 2011
Perhaps the book's main value is the depth of detail it provides in showing how to use PHP to implement a social networking website. The Model-View-Controller pattern is used, which should be no surprise to many readers who have prior experience in website coding. The book takes you through the development of an example website, stuffed full of numerous code snippets in PHP.
The driving motivation is used in a top-down manner. Typically, a chapter might talk about a desirable feature that you would want in your website. Like letting a user have different types of relationships with other users. Or, in related ways, letting a user accept or decline a relationship request from another user. Proceeding from this, the narrative flows into a discussion of what this means at the database level. Here's where you need a background in relational databases. Both the general theory of table design, and intertable relations, and also hopefully some knowledge of MySql.
The SQL code snippets can be quite intricate. A reflection of the underlying reality of dealing with a non-trivial database application. It is unclear how much effort you might necessarily want to invest in deciphering and checking the logic of each SQL snippet. These are tied closely to the example case, of course. Given that your website is unlikely to use the same tables, then simply as a pragmatic way of getting through the text, you can elide past doing such lowest level code analysis.
Another and closely related way of using this book is to look for only those features that you also want in your website. Then scrutinise the relevant sections of the text to see how easy it would be to modify the code. If you scan the introductory remarks in each chapter, you can quickly see what features are described. For those of you without the time to read cover to cover. The attraction is that if you can just find a few desirable examples, studying the code snippets could save considerable time, compared to you coding from scratch. Easily justifies the cost of the book.
on February 14, 2011
Short story: If you are fresh to social networks, this book will get you up and moving. It explains how to build a fully featured social network, based on a custom underlying framework. At the end of the book you will have a functional site, and know the what's what of social networks. It's very easy to follow the author, and the code is very readable. New concepts and features are introduced in a way that makes it easy for the reader to keep up.
Slightly longer story: I must admit that I'm having problems seeing the value of rolling your own MVC framework when building applications like this. The main arguments made in favor of going custom is ease of maintenance, licensing and code efficiency. I really don't buy these, as there are several good frameworks available under the BSD license, which are proven time upon time (Yii, Zend, Code Igniter, Symfony). Not only is the code maintained by teams of highly skilled developers, but also reviewed for security holes and exploits by the less good-mannered of our beloved internet. A *very* important aspect of social networking sites is security, and I feel that the book should spend more time on that subject (maybe including info on cross site scripting and related).
However, the one argument I really do see the value in is the process of learning. Writing a PHP framework is a very valuable exercise, and if you still have that on your TODO-list, this book should serve as a good guide on the way. The framework produced will allow you to keep extending and improving features after you are done with the material covered in the book.
on February 2, 2011
(Full disclosure: I was provided with a free PDF of the book by the publisher for the purposes of doing a review and a version of this review appears on my blog)
I'm glad I decided to take a look at this book. It's pretty dense at 450+ pages, but it really does work you through from start to finish how to build a small social networking site in PHP. Okay, it's about dinosaurs, but let's not quibble. I'm not into long-depth book reviews, so we can talk about what I liked about this book.
First, I admired the consistency in the approach. While I may not agree with all the decisions that they've made, or the coding style (we all have our own way of wanting to do things), but the author was incredibly consistent in how they're putting things together. It's all done in OOP, with attention paid on how to build on what you've already done. I mean, let's be honest here: most web apps of any significant size (meaning more than 10 lines of code) are very rarely internally consistent. People learn how to do new things. They start to hate how they've been implementing certain features in code. They get bored and decide to try out one of these 'design patterns' they've read about.
Not here. I think this is a very valuable lesson to be learned by beginning programmers. Once you've, you know, actually built a bunch of stuff that people other than your close friends use, you learn to refactor and improve your code. Your task gets much more difficult if the application itself is internally inconsistent. Like I said, I dunno if I would've made the same decisions as them, but damn it's slick looking code that looks the same no matter what they are doing.
It was also refreshing to see some attention paid to the concept of security in a web app. Not trusting user input, not storing passwords as plaintext (they even mention using a salt for your password), stuff like that. I still have some issues with there use of using $_SESSION as a totally trusted source, but I can admit there are limits to what you can do.
It's also rare to find a book that teaches you something while you are actually building something. If you were to actually sit down and type in every single code example, my guess is that you would have 90% of a completely working site. Building upon all that stuff you've learned by following the book along, it seems to me it would be easy to get it to 100%.
Just look at the sort of stuff you learn about:
* the Model-View-Controller pattern
* creating effective templates
* proper use of a registry object
* planning of relationships between data (along with use of binded parameters in your DB queries via PDO
* post-coding tasks like deployment, SEO, and figuring out how to get data from development into production
But here's the part you were all waiting for: what did Chris not like about this book. In a word: TESTING. There are no tests for ANYTHING in here. Yes, I know the testing vs. not testing flame war is on the same level as vim vs. emacs and mac vs. pc. But damint, we're 2 years into the 21st century! Integrating tests into your application isn't difficult any more. Okay, so places like Facebook are apparently not using unit tests. You are not Facebook, so don't give me that answer as an excuse. Facebook is a perfect example of a spaghetti PHP application that grew out of control and they were able to hire some top-notch engineers to untangle it and produce an amazing application. Slam th'em all you want, I have lots of respect for the people who continue to build and extend Facebook.
So, in summary, I highly recommend that beginning to intermediate developers check out 'PHP 5 Social Networking'. It is a good example of a very cohesive application that covers a very large number of scenarios that you are pretty much guaranteed to run into. Once you've had a chance to build something like this (many functions, cohesive architecture) you can then push your skills to the next level where you learn about refactoring and Demeter's Law and all design patterns. Until then, use this book as a reference on one way to build stuff.