Book Review: Ajax for Web Application Developers - Creating and Using the JavaScript Engine
(Page 2 of 4 )
This section has chapters on OOP (object oriented programming) and the approaches that could be used in it, with an in depth look at object constructors and Prototypes as approaches to OOP. Basically the Object Constructors approach is a deliberate way of structuring JavaScript so that your code is reusable, and can be modified (tweaked) to fit slight differences. In other words, it's just writing a regular JavaScript function to which you can add methods and properties to fit particular instances, an instance being the different property and method parameters. Hadlock uses this approach to create reusable code for properties in a web mail application he uses as a test application in the book. Using Prototypes as an approach simplifies the addition of properties and methods.
Apart from OOP approaches the section also has chapters which have loads of reusable code. There is some code for creating a JavaScript Object handling all your requests to your server; it checks the state of your requests and updates them depending on the response received from the server. All the while Hadlock consistently explains the logic behind all the geeky-looking code, making it much easier to understand and use. This section also has what is probably my favorite chapter, on debugging. Here Hadlock explains how to use various browser add-ons to debug JavaScript. Honestly, I find JavaScript hard to debug so this chapter is permanently book marked.
More reusable code appears in this section under "Extending the Engine." Code samples create objects which perform functions from editing your GUI to handling status codes and server errors (HTTP).
Creating Reusable Components
This is a beautiful section which discusses at length how to create your GUI and the different views it can have. Here he continues with his web mail example to describe how to use AJAX to display content dynamically and in an interesting manner, while giving you the option of using the code again when handling large amounts of data that needs to be displayed in a directory and file format. This section is all about your GUI, so there is a lot of CSS code in here too, as well as ergonomic ways of displaying large amounts of data. It made me understand more clearly some AJAX-like patterns I have seen on various web sites, such as the column command on Developer Shed's forums.
Again note that this section contains in depth code for his web mail application with the underlying logic beneath it, so there is a chapter on client side validation (form creations, data validation, feedback, tables and SQL queries). This section gives lots of reusable PHP/MySQL code which can be used in creating forms and tables to hold the information on the forms.
Next: Ajax Patterns >>
More JavaScript Articles
More By Akinola Akintomide