tags: apache   archive   business   charity   climbing   cluster   comic   database   email   exchange   family   fm2008   hack   humour   linux   liverpool   microsoft   money   mysql   network   oes   opensource   outlook   php   pictures   poem   process   project   real_life   review   rss   science   security   software   sql   thought   tsm   updates   webdev   website   windows  

(OOP) with PHP5

Mon, 14 Apr 2008 07:43:48

Since the release of PHP4, support for OOP (Object Orientated Programming) has been vastly improved. For those not familiar with (OOP) I offer a general overview. (OOP) is a style in which you structure your code. It differs from procedural programming as everything is grouped as objects. Objects then perform specific tasks within the module. This allows modifications to be made much easier without disrupting the flow of existing code. Another benefit is rapid application development as code duplication is reduced by including common functions already written by the developer or a 3rd party. PHP4 was the first version to really offer (OOP) handling but the implementation was poor in comparison to pure (OOP) languages such as Ruby on Rails. PHP5 has dealt with many of version 4’s inconsistencies and improved the language’s overall object orientated capabilities. Object Orientated Programming with PHP5 helps us understand many of the core (OOP) features within PHP whilst looking at the Model-View-Controller (MVC) design pattern and unit testing.

The author Hasin Hayder is a Zend Certified Engineer (Zend is a framework for PHP) and has 5 years experience working with PHP. This is the 3rd book which he has written and published through Packt Publishing with another one expected out in May this year (2008). Previous books have all contained an element of PHP and in his latest edition, it’s easy to forget he’s only been working with PHP for 5 years. This is the third book I’ve received from Packt Publishing with the intention of releasing a review online.

On the book cover it states being written for beginners to intermediate users and although I have two years experience, I consider myself a beginner. My prior development has been using a procedural approach and was hoping for a better understanding of (OOP) which I could utilise in the future.  Chapter 1 looked like an ideal introduction, “OOP vs Procedural Programming”. I found it difficult to understand as there were no clear indications of the differences. Now I’ve completed the book and re-read the chapter I have a better understanding of what Hasin is trying to say, albeit not very well. For an introductory chapter too much is expected of the reader, unfamiliar terms are used which set a precedence of complication throughout which is not a fair reflection on how the book progresses.  Chapter 2 “Kick starting OOP” does a great deal more for the reader by breaking down an object into its individual components.  The way an object is designed and interacts can be difficult to understand at first, Hasin does a good job explaining the concept allowing a foundation to be set on which the rest of the book is built. Clear and concise is the example as one would hope for such an important chapter.

Chapter 3 “More OOP” was like reading PHP.NET from page to page; we are shown many features but none of the added value one may expect to find in a book. Chapter 4 “Design Patterns” is the beginning of a theme which continues throughout, packing pages with code. Code in a programming book is expected, but there must be a balance between examples and descriptions. Design patterns are key to efficient application development and we’re introduced to many common approaches. Unfortunately I feel much of the valuable information will be lost as readers quickly turn pages trying to escape the aggregation of code which accompanies each pattern.

Chapter 5 “Reflection and Unit Testing” Again too much code used but the E-mail validation example and explanation about ‘Test Drive Development’ are very good. A lot to learn from this chapter and written to help those new to these techniques understand the core principals. It ends by including 10 pages from ‘PHPUnit Pocket Guide’ which was pretty meaningless as the author states himself, the function names are self explanatory.

Chapter 6 through 9 continue very much of the same, a lot of code with basic descriptions. Chapter 7 “Database in an OOP Way” is important and may have been better introduced earlier in the book. If you’re coding in PHP one of the first things you learn, is how to interact with a database. We get an overview of the ‘Data Abstraction Layers’ which are used in the majority of enterprise applications. They are very handy as they save you having to re-write chunks code if the backend database changes. We finish with Chapter 9 “Building a better MVC” which I really enjoyed. The code continues to flow but it’s relevant and very helpful. All major frameworks use the MVC design pattern and here we’re guided through building one from the ground up, including the MySQL table creation. We end with a basic blogging system which is an excellent way for developers to learn these new skills and all the code is available from Packt Publishing once you’ve purchased the book.

The book’s packed with code, more than required to guide you through many of the chapters and better explanations could have been used earlier on. The book may have benefitted from reordered chapters to address the more common uses of OOP first, easing the reader in. Object Orientated Programming with PHP5 is a good reference book with strong chapters on Database and MVC design. You can buy Object Orientated Programming with PHP5 directly from the publisher here

Enjoy
Ryan Partington

php
Visit site

CodeIgniter for Rapid PHP...

Thu, 28 Feb 2008 07:56:34

I started ‘CodeIgniter for Rapid PHP Application Development’ a novice. Previous experience was 2 years using Dreamweaver to build an application for my current employer. Dreamweaver uses a procedural approach to PHP whereas CodeIgniter focuses on Object Orientated (OO) logic. If you’ve not done any OO programming before then this book is an ideal introduction. CodeIgniter is a framework for PHP allowing you to build clean and sophisticated applications using an MVC (Model View Control) architecture. MVC put simply is a clean way to organise your code and once you understand the concept and become familiar with the CodeIgniters framework you’ll be building web applications in no time.

The book’s published by ‘Packt Publishing’ and like with all their books you can download the example code from their support page. The examples are pretty easy to setup and I had no problems getting any of them work. To be honest the details and explanations provided by the author make it very difficult to make a mistake.

The introduction for me was the hardest part to get through as I had no prior experience with OO programming or the MVC architecture. The concept was difficult to understand but I’m glad I persevered. I’m a more hands on programmer; learn from writing the code rather than reading about the methods. So once the book got start on using the CI framework to simplify common tasks I began to understand how and why my application design would improve. This book was not just about CI, but a new approach to efficient application development with all the hard work already done.

Once we’ve been introduced to the MVC architecture, chapters are broken down into common tasks. We begin by looking at how CI works with database connections and modifications whilst keeping the code clean and using a lot less characters. Initially I thought we were reinventing the wheel, learning new syntax to achieve the same results. Over time however, especially whilst troubleshooting, you find the application development a lot easier because it’s simple. You’re working with a much stronger and efficient foundation, not to mention the protection your code inherits.

Halfway through we get a look under the hood, how CI actually works. You will still want to write your own classes and here we’re shown how we can integrate them within CI. Being new to (OO) programming I scanned over this section as it focused very much on the CI ‘super-object’ which mothers the framework.

You may have heard about ‘Test-driven development’ which in a nutshell focuses on designing a ‘test’ environment before you even start writing your production code. The idea is you build your application and code to pass these predefined tests. A difficult concept to swallow at first and I welcomed a chapter which helps us understand this approach to application design. Once we’ve tested our application and we’re happy with the functionality how can we ensure we’ve not ended up with bloated code? Easy! David Upton (Author) shows us how we can easily benchmark our application using a CI class. Benchmarking is not always required, some smaller projects will not benefit from an extra fraction of a second, but if you’re building an enterprise class application, they can make all the difference.

There is a lot offered by the CI framework and the advantage of buying a book like this is we gain a practical understanding where and how we can use it. I’ve only scratch the surface of what’s on offer by David Upton who tutors you through each section, explaining the concept behind each class or helper. You’re not overwhelmed with code, but taught valuable lessons in approach and application.

I believe a someone similar to myself would be an ideal target audience; little or no prior experience of (OO) programming, or the MVC infrastructure, couple of years procedural PHP experience and after something that can really take you to the next level. You can buy CodeIgniter for Rapid PHP Application Development’ directly from the publisher here

Enjoy
Ryan Partington

php
Visit site

PHP Web 2.0 Mashup Projects Review

Fri, 18 Jan 2008 12:59:44

I’ve just finished reading a PHP book which looks at integrating content from various web services. For example we could mix up google maps with flickr and display user’s photographs of a particular area on the map. We use the APIs provided by the original developers, in this example, google and flickr to offer a new service. It’s advanced stuff and there’s a lot a new technologies to get your head around. To create these ‘mashups’ you use protocols like REST and SOAP which define and manipulate data formats like XML and XPSF. To read my full review, click (view page).

Enjoy
Ryan Partington

php
Visit site