Back to description
Object-Oriented (OO) software development can be a confusing topic for developers who create primarily procedural code. But... more
Object-Oriented (OO) software development can be a confusing topic for developers who create primarily procedural code. But it doesn’t need to be. In this chapter, you’ll explore some of the basic theory behind OO and cover its (sometimes daunting) multisyllabic terminology. You’ll learn why you should be interested in OO techniques, how they can really improve the speed with which you develop complex applications, and the ease with which you can modify those applications.
In the next couple of chapters, we’ll expand on the ideas and learn some slightly more advanced topics. If you have already had exposure to OO development outside PHP5, you can probably skip this chapter and the next. However, this material will serve as a good review, so we recommend that you read it through.
... less
If you’re the only programmer working on a small project, drawing a small sketch of the application on paper or keeping the... more
If you’re the only programmer working on a small project, drawing a small sketch of the application on paper or keeping the design completely in your mind is often sufficient. A solo programmer can usually complete a project without any problems this way.
Say that you were to get a larger project requiring two developers. You’re the one who’s responsible for designing the system, and the second developer is there to help you write the code. How would you communicate the design of this system to the other person? You could describe in words what classes were necessary and provide a description of how the system functions both for the end user and internally. After a while, you might end up with a lot of text describing the system. If you imagine a larger project, it quickly becomes clear that describing a large software system purely in words is not practical. If you created diagrams of your own design, you’d have the added task of explaining your system of notation to the other members of the team.
Another language exists, the Unified Modeling Language (UML), which was designed to solve this problem. UML is primarily a language of standardized diagrams, each of which lends itself to describing a particular area of software design. UML gives everyone the same way of “speaking” about a system and provides a powerful method of visualizing it.
Now that you have gained a good grounding in object-oriented basics from first two chapters, we’ll push on with a slightly... more
Now that you have gained a good grounding in object-oriented basics from first two chapters, we’ll push on with a slightly more complex look at how you can build a real application using object-oriented techniques.
Our chosen application is a contact manager that is intended to manage data about individuals and organizations and to enable users to look up and edit contact information associated with them. The discussion in this chapter is designed to present you with a good grounding in the issues behind creating working object-oriented applications. Along the way, it will also demonstrate how the major principles behind the object-oriented paradigm, such as code reuse, encapsulation, inheritance, and of course, abstraction, can be applied.
In the previous chapters you learned that objects can descend from parent objects via inheritance. You’ve also seen how objects... more
In the previous chapters you learned that objects can descend from parent objects via inheritance. You’ve also seen how objects can contain references to other objects, such as a DrumSet object holding Drum objects. In general, the technique of composing an object from other objects is referred to as object composition.
DrumSet
Drum
Both inheritance and object composition are powerful tools in designing object-oriented software and allow for a wide variety of design choices. Of course, having many choices does not always make decisions easier. How would you design your application so that it’s easy to maintain and extend? How would you write a component that the other members of your team could use through a simple interface? When writing software, you can solve certain problems on your own using your experience, intelligence, luck, large doses of soda, or any combination of the above.
You’ve probably reused existing code of your own to solve a problem. Perhaps you have a standard script for connecting to a database. Design patterns are a bit different in that they are not simply about reusing code; they are more abstract and generalized than that. The same design pattern can show up in completely different types of software. Design patterns are about reusing ideas. After you know a pattern, you should be able to recognize where it would be useful. Then you can go ahead and implement itknowing that it’s an accepted solution.
A design pattern is a specific way of solving a particular problem. In our case it represents the way an object or set of objects is structured, how they collaborate and communicate with other objects in the pattern. Each pattern has a descriptive name, such as Observer or Observable, and each pattern has a specific design that can be shown in a class diagram.
Observer
Observable
Patterns can be confusing at first. If this initial description doesn’t seem clear, don’t be concerned: You’ll be working through five different patterns in this chapter, building on some of the code you saw in the last few chapters.
Now that you’ve learned the ins and outs of object-oriented application design in PHP, you might be tempted to dive in and... more
Now that you’ve learned the ins and outs of object-oriented application design in PHP, you might be tempted to dive in and start coding your application. With your new-found knowledge, you’re certainly ready to do just that, but you will almost certainly be taking the longest route to get there. There are a number of shortcuts you can take along the way, in the form of a series of utilities and reusable classes that together will comprise an immensely powerful, easy-to-use development toolkit. In this part of the book, we’ll be introducing you to the toolkit piece by piece, and showing you with real-world examples just how useful it can be. The first class in your toolkit is called Collection, and that’s what you’ll meet in this chapter.
Collection
The Collection class is an object-oriented replacement for the traditional array data type. Much as an array does, it contains member variables, although those variables tend to be other objects, rather than simpler data types like strings, integers, and so forth. The class then provides simple methods to allow you to add member variables, remove them, and fetch them for use in applications. As you’ll see in this chapter, it has numerous advantages over using a simple array for storing a series of instantiated objects.
array
As with all chapters in this section of the book, you will not only utilize the code for the class itself, but will also see exactly how it is put together, based on original design requirements which we will determine together. Along the way, topics such as lazy instantiation using callbacks are discussed, as well as how to put the Collection class to use and what possible improvements could be made to it in the future.
In conjunction with the CollectionIterator class, covered in the next chapter, the Collection class provides a sophisticated but easy-to-implement mechanism for handling groups of objects in your application.
CollectionIterator
The previous chapter gave you a look at the... more
The previous chapter gave you a look at the Collection class, an object-oriented (OO) wrapper for managing an array of objects that’s a powerful and flexible part of the utility toolkit. On its own, however, it is missing some functionality. Namely, it does not provide an easy way to iterate over all its members. In the example application we saw in the previous chapter (a university registrar’s office), there existed a Student class that has a member variable called courses, which is a Collection. In this application, you would likely need a view that displays a list of all the courses for which a student is registered. To keep the syntax as simple as possible, ideally you should be able to do something like the following:
Student
courses
<?php
$objStudent = new Student(12345);
foreach($objStudent->classes as $objClass) {
print $objClass . “\n”;
}
?>
If you have some experience with PHP4, you’ll recognize the foreach statement as a construct that allows you to easily traverse the elements of an array. In PHP4, the only valid operand to foreach was an array. Any other data type caused a runtime error.
foreach
PHP5 has a way to allow foreach to work on objects, too. The built-in interfaces Iterator and IteratorAggregate work together to allow you to traverse the elements of an object that contains other objects, such as our Collection class.
Iterator
IteratorAggregate
In this short chapter, you’ll learn how to use these interfaces to enable your classes in exactly this manner, so that the foreach iteration method becomes just as useful for traversing collections of objects as it has always been for traversing regular arrays.
By now, you should be quite comfortable with the idea of object-oriented programming, as well as truly sold on all its benefits... more
By now, you should be quite comfortable with the idea of object-oriented programming, as well as truly sold on all its benefits. Indeed, OOP allows you to develop highly maintainable, clear, logical code that conforms more closely to a humanized version of your application. Yes, it adds some development overhead, but the benefits will be enormously clear should you, or anybody else in your organization, ever need to look at that project again.
One of the downfalls of this approach, however, is that you may sometimes have to sacrifice raw efficiency to achieve true compliance. For example, so many Web applications have simple pages that allow a user to edit an entitybe it a user, a product, an order, a customer, or whatever. The non-OOP approach is quite straightforwardan HTML form with a single UPDATE SQL statement to make the amendments. The OOP approach, by contrast, can seem frighteninga class called Customer, with goodness knows how many methods just to update its own properties in the database. The real downer is that huge chunks of the code you’ll have in each entity classthat is, in the classes representing users, products, orders and customerswill be replicated time and time again.
UPDATE
SQL
Customer
Thankfully, there is another way; it’s called GenericObject. In this chapter, you’ll be introduced to it and its sister class, GenericObjectCollection, and see how together they can cut your coding time in half while still allowing you to achieve true OOP compliance and all the benefits that brings.
GenericObject
GenericObjectCollection
Most of the enterprise-level applications you will build with PHP will at some point need to interact with a relational database... more
Most of the enterprise-level applications you will build with PHP will at some point need to interact with a relational database such as MySQL, PostgreSQL, Oracle, or Microsoft SQL Server. Many of the components in the toolkit presented in this book have some obvious integration points with a database. Unfortunately, PHP’s data interaction functions are very platform specific.
For example, to connect to a MySQL database, the PHP function is called mysql_connect. To connect to a PostgreSQL database, the function is pg_connect. The Oracle and ODBC APIs have their own names. The various database functions are similar, though not identical, across the different platforms. As a result, any change to the database platform on which your application runs will require changing all the database function calls. To help resolve this problem, a number of different open source and commercial projects have endeavored to create a unified set of data access functions that can work with any database. The main idea behind doing this is to allow applications to easily change the database they run on. In theory, you should be able to easily change from PostgreSQL to MySQL or any other platform.
mysql_connect
pg_connect
In reality, because of the differences between the different SQL dialects and the different levels of support for the SQL specification and the proprietary SQL extensions used by most databases, real portability between databases is neither a reality nor a necessity for most large-scale enterprise applications. However, because the components in this toolkit are designed to be generic and completely reusable between different applications, ease of portability between database platforms is a requirement for the components.
To make it easy for toolkit components to be reused between different applications, running on different platforms, this chapter will explore the creation of a database abstraction layer and take a brief look at some of the more popular database abstraction layer projects that exist.
You’ll also learn about an important design pattern called Singleton. The Singleton Design Pattern allows you to create exactly one instance of a particular class, and no more than one. This is useful when you have something like a database connection and you don’t want to allow the application to be creating lots of these connections during a single page request.
In previous chapters you have learned what a design pattern is and how you can make best use of them in your PHP development... more
In previous chapters you have learned what a design pattern is and how you can make best use of them in your PHP development. In this chapter you’ll see once again that design patterns are not just academic exercises but can be frequently and effectively deployed in real-word applications. Sometimes well-known patterns emerge without your even realizing it.
This chapter introduces you to the factory interface and sets out not only the situations for which it is most appropriate, but also how you can successfully apply it in your own programs.
To help you get the most out of this chapter, we will introduce some code examples that make use of factory interfaces. We also discuss how those code examples can be improved with the new features of PHP5, taking care to note any important implementation details along the way.
Sometimes it is useful to think of applications in terms of events and how best to handle them, rather than look at that... more
Sometimes it is useful to think of applications in terms of events and how best to handle them, rather than look at that application’s architectural design from a traditional object-oriented perspective. That’s not to say that we must discard an OOP approach altogether to implement event handling, rather that we build classes around the events relevant to the application. This approach is rather radical, but for many applications you may find that it gives you a massively powerful mechanism for approaching the software architecture of the whole project.
Events occur pretty much all the time, and some of the best examples of event-driven programming are the applications we use every day to manage e-mail or write text. For the end-user, Windows- based programs, event handling is of paramount importance. This is because these applications are designed to lurk around until the user does something and then react accordingly. Of course, the same is now true for many Web-based applications. Anything with a GUI is a likely candidate for the event-driven programming paradigm.
Nearly all actions taken by a user, and even those taken by the applications themselves, can be thought of as an event. A rather contrived example of an event not initiated by a user is your machine’s clock. If you wanted to create an application that performed various actions depending on the time, you could capture certain changes in time as an event, and bundle it off to a piece of code that deals with it accordingly.
Whatever needs to be done, applications have various ways to implement a solution, and PHP5 is no different in this regard. There is, of course, no new extension or library to deal with events, because the way we deal with them is more about how we “think” about designing an application rather than how we actually implement it. In other words, they need no special underlying technology. Let’s take a look at one way to handle events in PHP.
In every application you build, robust logging and debugging mechanisms can save you hours of effort trying to track down... more
In every application you build, robust logging and debugging mechanisms can save you hours of effort trying to track down problems that might occur.
Logs can be used to help you analyze historical usage patterns that can’t be obtained through the Web server log, such as server load, specific SQL statements that were executed, or application-specific messages that wouldn’t otherwise be captured.
A debugging mechanism allows you to examine the values of variables, see which conditional loops are being executed, or otherwise determine the state of the application at runtime without having to litter your code with print statements that will need to be deleted before you deploy. After you’ve worked through the code in this chapter, you’ll have a set of classes that should be a part of every project you work on.
print
It is becoming more apparent these days that applications can no longer live in a vacuum, but are instead required to interact... more
It is becoming more apparent these days that applications can no longer live in a vacuum, but are instead required to interact with other systems in some way or another. There isn’t one great big chunk of code on a mainframe computer dealing with absolutely everything anyone could need. Phrases like “loosely coupled” and “code-reuse” are winning the day because they make it easy for developers to effectively “piggy-back” a ride on the work of othersor, at the very least, separate and isolate different functionalities, making it easier to modify or maintain their code.
Code reuse implies that once something is done, we don’t need to reinvent it. Instead, we ask the inventors nicely if we can incorporate their work into our own project. Looking at this phenomenon from a pragmatic point of view, we can see the results of this decoupling of functionality, and code reuse, evidenced by the multitude of Web Services that are present on the Internet.
Of course, part of not reinventing the wheel each time you need to accomplish something means that communicating with legacy systems is also necessary now and then, and quite a lot of work has and is being done to ensure seamless communication between older systems and the new ones being rolled out.
The upshot of this distributed, loosely coupled architecture and design paradigm is that communication is more important than ever. Whatever the communication needs of modern systems are, it is a safe bet that somewhere along the line XML will come into play as the transport medium of choiceand if that is not quite true now, it will be true soon enough.
XML is a huge topic and we don’t cover it in great detail here. We assume that you have a basic knowledge of XML in order to use this chapter. And if you’re not familiar with XML but would like a good grounding, you might want to take a look at Beginning XML, 3rd Edition (Wiley, ISBN 0-7645-7077-3). However, having already advocated the use of XML as a mechanism for allowing applications to communicate with one another, we spend this chapter looking at how SOAP (Simple Object Access Protocol) can be used to implement XML based communications in PHP5.
When PHP first arrived on the scene, a minor revolution took place. Interactive Web applications, once the preserve of the... more
When PHP first arrived on the scene, a minor revolution took place. Interactive Web applications, once the preserve of the development professional, were springing up left, right, and center. Suddenly, some seemingly sophisticated interactive Web content, which went well beyond the traditional guest book CGI script, was appearing in some very surprising places.
The reason for this revolution was the enormous accessibility of PHP. It’s not just that the “hello world” program was refreshingly easy to implement. Even traditionally complex procedures such as database integration became possible with just a few lines of code.
The problem, however, is that this accessibility was quickly abused. In some cases, it resulted in complex applications’ being built by inexperienced development staff. In others, previously dedicated professionals understandably let their traditional values lapse slightly in the face of enormous temptation to take advantage of the simplicity PHP offered.
The risk associated with such development is obvious. Such abuse has led to unmaintainable applications on a shocking scale along with well-documented cases of instability, unreliability, and even exploitable security holes.
Although many programming languages such as Java and C++ enforce good programming practices through their design, PHP requires self-discipline. The difference between a seasoned PHP professional and a bedroom coder is exactly thatself-discipline. One of the most notable examples of such best-practice methodology is that of the model, view, controller (MVC) pattern.
In this chapter, you’ll learn what MVC is all about and why it’s a great methodology to use in your own programming. You’ll build up a useful toolkit for handling some core parts of the MVC principles and learn how to use them in your applications.
Finally, you’ll be introduced to two effective ways to implement the use of templates in your application and how to use templates alongside the MVC toolkit you’ve just met.
The Web is a simple method of communication when you come right down to it. The end user requests a page, things happens... more
The Web is a simple method of communication when you come right down to it. The end user requests a page, things happens in the background, and the Web server fires back some content in response. Repeat ad infinitum. But if you limit yourself simply to talking to users through their Web browsers, you’re missing out on a very big part of what makes a truly impressive user interface.
In this chapter, you learn about the building blocks of user communication and how it translates into an extraordinarily natural PHP object hierarchy. You’ll see how you can extend and develop this hierarchy to support virtually any form of electronic communication. You’ll also see practical examples of implementing some functionality that PHP doesn’t provide and that you may find useful in your day-to-day development.
Perhaps most important, you’ll learn why you should communicate with your users in the first place.
Despite the advancements of PHP in recent years that have brought it to the full-featured, object-oriented Web application... more
Despite the advancements of PHP in recent years that have brought it to the full-featured, object-oriented Web application development platform it has become today, it still relies, as do all other languages of its ilk, on the basics. That is, it relies on the HTTP protocol and the CGI (Common Gateway Interface, the most basic building block of any kind of interactivity on the Web) functionality that HTTP provides.
When people speak of HTTP they often describe it as statelessmeaning that no “memory” is retained from one user’s request to the next; the request is made via GET or POST, data is returned, and the request is completedand, as far as the Web server is concerned, forgotten.
GET
POST
This characteristic isn’t much use if you’re trying to build complex Web applications that emulate the functionality of their equivalent desktop counterparts. You need to be able to keep track of users’ previous actions, not just what they’re doing right at this moment, in order to be able to produce meaningful output. Thankfully, PHP provides a way around this: sessions. This technique allows you to maintain certain stateful information from one request by the user to the next. This leads very neatly to one of the most common and useful applications of session handlingthat of authentication and user state persistence.
The first half of this chapter discusses PHP’s built-in session-handling features. You’ll see that although on the surface the functionality available to you may seem basic, it can be extended and adapted to provide enormous degrees of flexibility, including integrating with third party databases. You’ll also learn the ins and outs of session security so that you can devise session architectures that keep hackers at bay.
In the second half of the chapter, you’ll learn how to apply this knowledge of session management to develop an essential component of your toolkit: a reusable, database-driven authentication class that can be deployed on almost any Web site that needs users to authenticate at some stage.
One of the main benefits of structured, modular programming in any language is that the components you develop will nearly... more
One of the main benefits of structured, modular programming in any language is that the components you develop will nearly always be self-contained. They can be cleanly taken away from their mother project and worked on in their own right, and this includes testing.
Making sure that a component does exactly what you want it to do is an essential step in application development. As you will have already learned elsewhere in this book, it is vital that components are tested before they are integrated with the bigger picture application. Always write the application around the components. Never write your components around your application.
For slightly more complex classes (or even hierarchies of several classes), devising a suitable test strategy can appear quite tricky. The temptation to resort to spitting out huge chunks of data with var_dump() to the error log can be overwhelming, but you should resist it because you can save yourself a great deal of time by using a prewritten Unit Testing Framework. Not only that, but a coherent, thorough, and professional approach to testing is something you can actively demonstrate to your clients (or your boss), whereas having hundreds of error_log() statements is not.
var_dump()
error_log()
There is indeed such a framework available for PHP, a semi-official one called PHPUnit. In this chapter, you’ll learn not only how to install and use PHPUnit but also why it’s so useful on a day-to-day basis. At the end of the chapter, we cook up a class with some deliberate but hard-to-spot logic errors and use PHPUnit to fix it.
Most people would argue that PHP is a modern language, designed for modern applications. As are almost all modern Web development... more
Most people would argue that PHP is a modern language, designed for modern applications. As are almost all modern Web development languages, it is regarded as being high level. It concerns itself more with rapid application development instead of allowing its programmers to fiddle with the underlying system directly for the sake of optimizing performance.
Indeed, languages that are particularly high level, such as PHP, further widen the gap now firmly established between programming in the traditional, computer science college-textbook sense of the word, and application development (using the language as simply a tool designed to solve a problem).
For example, it was not so long ago that games programmers were locked in a battle to determine who could produce the fastest assembly-language putpixel routine, to draw a single pixel on the screen. Nowadays, however, few games programmers concern themselves with such low-level matters, preferring instead to make use of Microsoft’s DirectX library, which pretty much has it cracked. In much the same way, PHP takes the burden of developing low-level, highly tuned, optimized routines away from the programmer and exposes only useful functionality instead“tell me what you want me to do, not how you want me to do it.”
putpixel
However, some of the more traditional programming techniques also have a role to play in PHP. We’re not suggesting or recommending trying to get PHP to execute register-level CPU instructions, of course, but there is one more elderly concept worth resurrectingthe Finite State Machine.
In this chapter, you’ll meet the Finite State Machine in some detail, including learning what it does, how it does it, and how it can prove to be a useful solution to a variety of the more difficult and awkward challenges you might face in your own projects. After learning the basics of the FSM model, you’ll meet a PEAR class that enables you to quickly and easily implement a basic FSM in PHP. As a proof of concept, you’ll meet a simple programming puzzle solved using the FSM PEAR class and then dissect it piece by piece. In the process, you’ll discover why that puzzle lends itself so well to implementation using an FSM, and how you might easily identify similar opportunities yourself. In the second half of this chapter, you’ll look at the concept of user-modifiable configuration files, which provide an excellent example of an off-the-shelf Finite State Machine implementation. You’ll see why they’re important, what the role they play in your applications, and how best to go about implementing them in PHP.
Writing software is hard. If it were easy, you wouldn’t be bothering to read this book and we’d all be enslaved by machines... more
Writing software is hard. If it were easy, you wouldn’t be bothering to read this book and we’d all be enslaved by machines by now, so thank your blessings that it’s not a trivial task.
But why should software development be hard? It requires no purchase of paint or canvas, and it binds you by few physical constraints. It should be the ultimate blank slate, yet one of your biggest impediments is that of logically painting yourself into a corner. In essence, your very own mind is one of your biggest enemies.
Another constraint is time. Although few things are technically beyond your means, you are mortal and cannot possibly physically create something as powerful and flexible as the entirety of the GNU/Linux operating system in just two weeks.
And for whom is this software written? Yourself? Your friends? A rather common scenario is writing custom software for a client. The fantasy client used as an example in this chapter is called “Widget World.” The type of scenario it presents is very common, because the majority of software is not written for consumers but rather to meet the specifications of businesses, governments, and other groups.
The rest of this chapter assumes that you’re an average developer, working on an average project at an average company with average clients. For simplicity’s sake, however, we’ve given this example project some perhaps uncommon traits:
You are developing a new product. (A much more common scenario would be to modify a currently existing system.)
You are working alone because you are reading this text alone. (In the real world, you would most likely be working closely with or interfacing with other developers.)
As a Web development professional, you might be curious to know whether a software architect can effectively manage projects... more
As a Web development professional, you might be curious to know whether a software architect can effectively manage projects. The answer is, “Yes! Provided that you have a bit of training under your belt.”
Even if you are never confronted with your own project to manage, you will find it immensely useful to understand what the project manager, who is running the show, has to contend with on a daily basis. It will make you stronger as a software architect and as an individual to understand and be sympathetic to the skills required to run a successful development project from start to finish.
And in the event that you do find yourself in charge of a team of bright-eyed young developers one day, you’ll find that the skills gleaned from this chapter and the next will serve you well.
This chapter discusses how to collate business requirements into a coherent brief and how to respond appropriately with a rock-solid specification and project plan. You’ll learn how to identify and select the key personnel you need to work underneath you, as well as how to guide and manage them throughout the project life cycle. You’ll also look at a couple of programming paradigms, discover how to evaluate their usefulness for your own project, and look at the two key approaches to tackling the development work on the shop floor. Finally, you’ll discover how to effectively manage your working relationship with your clients.
Admittedly, this chapter doesn’t have a whole lot to do with PHP. Nonetheless, the material covered is very relevant to any PHP project you might work on, even though the techniques demonstrated apply just as much to ASP, Javaany language. We decided to include them in this book nonetheless because they might well revolutionize the way you tackle big projects.
Developing complex, dynamic PHP business applications with a team of technical and business professionals is not a simple... more
Developing complex, dynamic PHP business applications with a team of technical and business professionals is not a simple prospect. You’ll be faced with many challenges, some of which won’t be entirely technical in nature.
The business-planning framework that you choose to work with will certainly affect the direction in which your software project grows. Choosing a process that offers a strict yet comfortable structure will place limits on how dynamically your project can change, but conversely reward you with a paper trail and a detailed road map to follow. Taking a more dynamic approach to planning may, however, mitigate the risk associated with technical or business unknowns.
The choice of which approach to system planning best fits your project is not one to take lightly, and you should be familiar with all planning options before making your decision, regardless of your personal or professional preferences.
By now, you probably can’t wait to get started and build your application. You’ve planned the system, chosen your people,... more
By now, you probably can’t wait to get started and build your application. You’ve planned the system, chosen your people, selected an appropriate methodology, and gleaned specifications detailing exactly what it is you’re going to build. There is, however, one final step you need to consider.
As a software architect or project manager, you may well be tempted to overlook the systems side of things. After all, you only build the thing. It’s somebody else’s problem as to how it gets deployed, right?
Well, that may be true, but having the moral high ground doesn’t get Web sites launched. At the end of the day, if it’s your application that’s not running up to snuff (or worse, not at all), the blame is going to rest squarely on your shoulders.
In this short chapter, you’ll learn the basis of systems architecturewhat it is, why it’s important, and how to effectively design one appropriate for your project based on the decisions you’ve already made about the architecture of the application itself.
Now that you understand how the technology works, this is your chance to put it together as a cohesive whole. This chapter... more
Now that you understand how the technology works, this is your chance to put it together as a cohesive whole. This chapter is about developing software from the ground up, and because it is a small project, you’ll be utilizing many of the techniques of eXtreme Programming.
With all the fanfare and drama of starting on a new important project, it’s easy to mentally jump ahead and start thinking about how to do stuff when you should be trying your best to consider what should be done.
So put your computer away, forget about your logins, passwords, databases, and just for now you won’t need PHP, either. Instead you’ll be using a technology that humans have spent the last few millennia refiningpaper.
Yes, paper is technology. It’s ubiquitous, inexpensive, readable even if wet, requires no batteries unless you’re in the dark. The same media type supports both write-only, rewriteable, and color and black and white inks. When paper is cut into small index-sized cards they can be used quite nicely for representing your PHP classes, they are moveable, and they can be mounted on a wall, traded, stapled, clipped, sorted and stored.
In short, your design and development process depends just as much on social interaction, wits, and thousand-year-old technology as it does on computer hardware and software.
Your Sales Force Automation project is looking pretty good. You’re on schedule and on budget, and the client is, thus far... more
Your Sales Force Automation project is looking pretty good. You’re on schedule and on budget, and the client is, thus far, happy with the beta version running on your development environment. Furthermore, by employing rigorous unit testing throughout the build process in the previous chapter, you can be sure that the individual components that comprise the application all function more or less correctly independently, and hence there shouldn’t be any deep-rooted problems in the code itself.
At this time, you might well be tempted to let your guard down. In fact, you have now reached one of the most critical stages in the entire project. The application is more or less complete and the client is urging you to let him or her use it. You must resist, however.
Quality assurance, usually abbreviated to QA, is a term you might be familiar with. Indeed, it is borrowed from traditional manufacturing and engineering processes and is the kind of procedure you expect to be carried out on your new DVD player or luxury family sedan. Why would you not, therefore, want to apply it to something as complex and crucial as your application?
In this short but crucial chapter, you’re introduced to the process of quality assurance in large-scale PHP projects. You’ll learn about why quality is of great importance and what it means in terms of your expectations and those of your client. You’ll learn about the kinds of testing you need to do to confidently be able to give your application a seal of approval, and how to get your team on board to help you when things go wrong.
Your Sales Force Automation application is now not only fully developed but also fully bug free , thanks to some thoroughgoing... more
Your Sales Force Automation application is now not only fully developed but also fully bug free , thanks to some thoroughgoing quality assurance in the previous chapter.
The process of getting your application uploaded onto a production server might have seemed simple enough when you first started out in Web development, but for a true professional there is, as ever, a best practice to be followed. This best practice is not just posturing. It is vital to version control and quality assurancetwo subjects touched upon elsewhere in this book.
In this short chapter, you’ll learn about structuring a server environment for a development team and managing the transition of source code between each server. You’ll also examine how and when to apply each transition to match the immediate commercial objects of both your team and your client.
With your project deployed and the client thrilled to bits, you may be tempted to dust your hands off, walk away, and look... more
With your project deployed and the client thrilled to bits, you may be tempted to dust your hands off, walk away, and look for your next challenge in life, be it PHP related or not.
You would be wise to avoid leaving the country too quickly, however. In addition to the client’s inevitable tirade of functional change requestswhich will require at least discussion, if not implementation as wellyou are also highly likely to be deluged with requests for data.
After your solution has been up and running in a production mode for a few weeks, a myriad of data will have been collated in the database. If your project was a simple e-commerce site there will, if you’re lucky, have been sales made. In the case of our Sales Force Automation tool, data on the activity of our salespeople will have been recorded. How do you turn this raw data into something usable?
In this chapter, we look at this challenge and see how you can best rise to meet it. In the first section, you learn the basics of reporting, including the kind of requests that are typically made and how best to accommodate them. Then we examine an intelligent approach to the systems architecture of report generation and determine the best way to deliver reports to your clients.
If you somehow managed to make it this far without touching a computer, please refer to at least a few of the previous 25... more
If you somehow managed to make it this far without touching a computer, please refer to at least a few of the previous 25 chapters. Humans tend to learn very well by physically doing what they’ve learned. Go back and pick up a chapter or two that pique your interest and feel free to experiment with the code. The adage “You get out what you put in” has never been more appropriate.
This should ring true even if you’ve scrupulously read every paragraph and run every application. After all, you’re sure to have experienced a thought that starts with: “What happens if \ldots?” Don’t know the answer? Can’t find it in the documentation? Experiment. There is no shame in breaking code by exploring boundaries, and by now your PHP skills should be up to a critical point. You can dig yourself out of any hole that you’ve managed to get yourself into.
This is an important distinction. Digging yourself out of a hole by using your technical skills, leveraging unit tests, and pondering the how’s and why’s means that your education can continue and, we hope, extend itself beyond the technical realm.
Many programmers dread big projects, often for a whole host of reasons.However, one particular aspect to big projects can... more
Many programmers dread big projects, often for a whole host of reasons.However, one particular aspect to big projects can sometimes seem more unappealing than any other code organization. Six or seven software developers, two software architects, a lead architect, and client-side developers all working on the same project often represent a recipe for disaster.
Mercifully, code organization on big projects has been made much easier in recent years with the advent of readily available, straightforward version control software.
In this short appendix, you'll encounter the basic principles of version control and see how to organize a version control strategy for your project. Then, you'll learn how these principles are applied in the most popular version control software and how to choose which (if either) suits your project best.
Many developers still tend to program PHP with their favorite editor and have developed their own preferred methods of debugging... more
Many developers still tend to program PHP with their favorite editor and have developed their own preferred methods of debugging their code. But, with millions of developers using PHP, the fact that Integrated Development Environments (IDEs, sometimes abbreviated to Development Environment, or DE) are not as widely used as, say, Visual Studio .NET is for ASP .NET is a bit of a mystery. This may be down to the fact that many people still don’t view PHP5 as a full-fledged programming language in its own right (we hope that from what you have seen in this book, you believe otherwise).
At any rate, PHP5 is a full-fledged programming language, and IDEs for it do exist. If you haven’t been developing using an IDE that supports PHP5, this appendix is for you. There are a host of useful features packed into the IDEs that might make the investment worthwhile to you. One of their biggest uses, of course, is the sophisticated debugging facilities that most IDEs provide.
Although this appendix won’t give you a fully comprehensive rundown of each IDE out there, it will give you an idea of what you can expect from some of the main ones, and an idea of what else is available. For the most part, you should be able to get a deeper understanding of the functionality of each of the DEs from their documentation. We cover the Zend Studio Client first, and in more detail, because this is the largest PHP-centric DE on the market. Following this, alternatives such as Komodo will briefly be explored.
PHP is extremely quick. In fact, for many applications, both simple and complex, PHP can beat the likes of Java, ASP, ColdFusion... more
PHP is extremely quick. In fact, for many applications, both simple and complex, PHP can beat the likes of Java, ASP, ColdFusion, and ASP.NET with very little work.
Sometimes, however, the need for speed will be of fundamental importance to the overall success of your project. At these times, gaining that last drop of performance can mean the difference between success and failure, so planning your application with speed in mind is vital from the outset.
But there are other reasons for using PHP. For example, you may have inherited a poorly written application from another party and need to increase performance without spending money on new hardware. Although it’s rarely pleasant working with other people’s code, especially those who have not been lucky enough to read this book, you’d be surprised how easy it is to squeeze seconds off.
In this appendix, you’ll learn to identify the different types of performance bottleneck and how to track down their culprits. Then, you’ll look at how to design and code for optimum efficiency and speed, as well as how to retroactively repair bad code you’ve been unfortunate enough to inherit.
These days it seems anybody can handle a simple installation. Even your mom and dad could probably handle popping the latest... more
These days it seems anybody can handle a simple installation. Even your mom and dad could probably handle popping the latest version of Windows on their PC.
The exception to this rule seems to be server applications such as PHP. Although the PHP Web site and supplied documentation do touch on how to get it up and running, they really go as far as telling you exactly that getting it up and running. Having a usable installation is quite a different matter and requires some inside knowledge.
In this short appendix, you’ll learn the ins and outs of getting PHP properly set up in a configuration best suited to the kind of enterprise development detailed in this book. We also look at the differences between PHP on Windows and PHP on UNIX, and examine which is better suited for enterprise development.
If you haven’t yet got PHP up and running, start here before you attempt the rest of this book.
Purchase Before purchasing this product, please be sure you have met all software and system requirements, and that you understand any limits placed upon its use.
Return Policy Wrox Chapters on Demand are non-returnable and non-refundable.
Watermarking Wrox Chapters on Demand are sold with a small unique watermark at the bottom of each page identifying the purchaser name, email address, and order number.
Reader Software Wrox Chapters on Demand are offered as PDFs, and they can be viewed using the Adobe Reader, ADE, or a compatible PDF reader. If you do not have the Reader installed, it can be downloaded for free at Adobe.com.
Test Download As Wrox Chapters on Demand purchases are non-returnable, it is advisable that you test your system and software configurations with a free sample download before you place an order.
Usage Rights for a Wrox Chapters on Demand File Any Wrox Chapters on Demand product you purchase from this site will come with certain restrictions that allow Wiley to protect the copyrights of its products. After you purchase and download this title, you:
If you have any questions about these restrictions or need any further assistance please refer to Technical Support (www.wiley.com/techsupport) or call (877) 762-2974 (8 a.m. - 5 p.m. EST, Monday - Friday).
Related Books