Oct 07

Book review: jQuery Succinctly

jquery_succinctly_download

 

  1. Introduction
    For developers, there is a need to keep up to date with the latest technologies, in a rapidly changing landscape. While the internet does allow for easier access to information resources, the truth is that there is probably nothing like a good book to provide a structured approach to a given technology. With a book, readers can benefit from the author’s experience and knowledge right from the beginning, and can be given a guided tour that makes learning probably a lot easier than going through a series of website articles.

    Recently I became aware of a series of free books made available by Syncfusion. I am sucker for books, so I downloaded a few, relevant to some of the technologies I use, to check them. One of those books is the subject of this review – jQuery Succinctly. The book author is Cody Lindley, described in the book as having been a jQuery evangelist with the jQuery team.

    jQuery is one of the technologies that powers the Web, these days. In most websites with a great user experience, most certainly jQuery is used to provide such experience. So my goal on reviewing this book is to evaluate it as a useful resource for someone wanting to how to use it for website development.

  2. Book Structure

    The book is organized in 10 chapters, starting with Core jQuery and including chapters such as Selecting, Traversing, Manipulation, HTML Forms, Events, jQuery and the web browser, Plugins, Effects and Ajax. This seems a decent coverage of the subjects related to jQuery to allow any developer to use it effectively for website development. The presentation is supported by examples, that are usually well chosen and helpful. The code can be downloaded, making it easier to follow the examples as the reading proceeds.

     Chapter 1, Core jQuery, introduces the reader to the core concepts of jQuery – in the words of the author, “find something, do something”, that is then extended to “create something, select it and do something with it”. This chapter also deals with other relevant introductory aspects like dealing with the wait for the DOM to be parsed or waiting for the full window to load, jQuery chaining, jQuery methods that break the chain and how recovery from such destruction can be achieved using end(). It also introduces the this keyword, iterating over multiple selected elements using .each(), accessing selected elements by index using get() and creating DOM elements. The chapter provides a decent introduction to all these subjects, even if in a rather brief way. 

    Chapter 2, Selecting is devoted to DOM elements selection. It starts with a presentation of filters or, as some other authors name them, jQuery type extension selectors. The is() method, to determine if a given element is present in the selected set of elements and the length property, are presented. The chapter also shows how custom selectors (filters) can be created, when jQuery does not provide the selectors you may need. A decent presentation of selectors that explore relationships between elements follows, as well as selector stacking and nesting. I found the chapter quite interesting and it did cover some selection techniques I hadn’t found in other jQuery books I read before.

    Traversing is the 3rd book chapter, dedicated to DOM traversing. Strangely it starts with the filter() and find() methods, which probably would make more sense in the previous chapter. The coverage is succinctly good. The DOM traversing methods parent(), parents(), closest() are introduced and differences explained. Other traversing methods are also briefly addressed.

    Chapter 4, Manipulation, addresses the creation, operation and addition of HTML, using jQuery. HTML creation is exemplified as is the addition of such HTML to the DOM using appendTo(). The Index() method and why you’d use it is also presented. The use of text() and other methods such as replace(), contents() or remove() are exemplified.

    Chapter 5, HTML Forms, presents jQuery features to handle HTML forms. The attr() and removeAttr() methods to change or disable form elements, as well as the use of filter attributes such as :enabled and :disabled. Radio and checkbox selection and checking is exemplified, using val() and filter attributes such as :checked or :hidden. Use of val() to set the value of input elements and <textarea> is presented. Multiple examples are given of common tasks of elements edition, using methods such as prepend(), html() or replacewith(). Form elements selection by type is demonstrated through examples. Overall, the chapter is a good read but, similar to what I found regarding Ajax as a general subject, it is a shame that Ajax form submission is not covered.

    Chapter 6 deals with Events. Dealing with events is one of the most important features of jQuery and the chapter covers the subject nicely. It starts with an explanation about how there can be multiple ready() events declared. It then addresses the use of bind() and unbind() with multiple handlers. It also shows how event handlers can be invoked through short methods and addresses the event normalization performed by jQuery, showing how access to the normalized event can be achieved. Event namespacing advantages, and how namespacing can be achieved, are presented. Event delegation is introduced and its advantages are highlighted. The use of live() to bind event handlers that will be applied even to DOM elements created after the binding is perform is also shown and the methods specificities are explained. Preventing the browser from taking default behaviors or stopping event propagation, using stopPropagation or using return false, when opening a link or submitting a form is also addressed. The creation of custom events using bind and their invocation using trigger is also presented, as is cloning events using clone. I found this to be a very interesting chapter, addressing most situations a developer may need regarding event handling.

    Chapter 7, jQuery and the browser, is a bit of a weird one. It covers two small subjects only – disabling the right click button and scrolling the browser window. In its succinctness, it’s pretty similar to chapter 10 and I confess I fail to see the point of having a chapter with such small amount of content.

    Chapter 8 addresses Plugins. It starts with the recommendation to use the $ alias only within a private scope to avoid conflicts and the way to do that is demonstrated. The use of $.fn to make plugin methods chainable, just as jQuery native methods, is explained and exemplified. Default and custom plugin options are presented. Programmatic invocation of plugins is addressed. Although useful and addressing relevant contents related to the subject, a reference to utility functions could have been made, even if succinctly.

    Chapter 9 deals with Effects. This chapter starts in a bit of a weird manner. The first statement is that all jQuery animation effects can be disabled by setting the value of the off property to true. If you consider that the book may be read by someone who never used jQuery’s animation effects, this introduction may actually lack some context. The text proceeds in the same tone by stating that the stop() method should be used to stop an ongoing animation, before starting a new one. The rest of the chapter discusses the use of show(), hide() and toggle() without animation. Exemplifies sequential and non sequential animations, using animate(). Presents it as a base abstraction and offers detailed suggestions on how it can be used. The chapter also presents jQuery’s fading methods, fadeIn(), fadeout() and fadeTo()

    Chapter 10, Ajax, address jQuery Ajax related features. I found this chapter a bit disappointing. It basically presents the $.ajax() function as the low level abstraction by the shortcut methods load(), get(), getJSON(), getScript(), and post(), but without actually providing examples of their use. There is another additional paragraph stating that jQuery supports cross-domain JSONP and shows how browser XHR requests caching can be disabled – this is a piece of actually useful info, much to the contrary of the rest of the chapter.

  3. Conclusion

    The author states, in the book introduction, that the book was written to express the concepts essential to intermediate and advanced jQuery development, with each chapter containing concepts essential to becoming a jQuery developer. I confess I didn’t really look at it under this perspective. Although maybe a bit unfairly, I suspect, considering Syncfusion’s audience, that it will be used, at least in a relevant part, by developers fluent in Microsoft’s web technologies, to become familiar with jQuery, to use it in the development of websites. So, from a web developer’s point of view, I found the book rather useful, with some very good chapters (2, 5 and 6 are my favorites) and others not as good (especially 7 and 10). Even if some chapters could benefit from a bit better coverage of the underlying subjects or a better organization, the book can be a valuable resource. All the subjects are dealt with in a succinct manner, which is the purpose of the Syncfusion ebook series, anyway, which means it cannot probably be the single book to have on jQuery, but it does provide some valuable information and you can’t beat the cost. It is also a book that you can keep nearby, to be used as a reference. I will keep my copy within easy reach.

 

Oct 06

My links of the week – October 6, 2013

Our weekly reading found a lot of interesting posts, this past week, so making a choice on the posts to include was quite hard. Again, some posts were not originally posted this week, but they are interesting enough. So let’s begin.

  • Richard Morris’ Developing for Delivery, a Practical Example addresses the difficulties of keeping a database current, when the database exists in a multiple number of sites, in a wide range of versions and how such difficulties were addressed by Calvi, a provider of telecom invoicing software. From personal experience, this is not an easy thing to achieve, even at a smaller scale, and the article provides interesting advice on how changes in processes and the use of adequate software tools can help reduce the difficulties involved.
  • Alex Bolenok’s NULL in SQL: explaining its behavior is a very good article on the idiosyncrasies of NULL behavior in SQL. The use of NULLs is not at all clear, especially for developers less familiar with the workings of databases, so the article is almost of mandatory reading. Most interesting.
  • Microsoft’s SQL Server Development Customer Advisory Team’s SQLCAT’s Guide to: Relational Engine is a free ebook that includes relevant posts from SQLCAT’s blog, from 2005 to 2012. Recommended.
  • Rob Farley’s Spooling in SQL execution plans is a few month’s old post, but one that clearly shows why spools are used in SQL Server execution plans and why they are not that bad.
  • Alex Popescu’s The premature return to SQL is a response to one article include in last week’s links, by Jack Clark, in which the author explains why the premature return to “SQL” is wrong – this “premature” return is motivated by an attempt to capture financial gains, does not consider the fact that many NoSQL products, in spite of having not yet reached technical maturity, have already provided valuable, alternative new doors to data and results, basically, from pressure from database vendors. 
  • Uncle Bob Martin’s Dance you Imp’s is a humorous but no less interesting article on Object Relation Mappers and the impedance mismatch between OO and the RDBMS storage used to persist them. In a very funny way, the author concludes that there is actually no object to relational mapping. A very interesting read.
  • Jimmy Bogard’s Scaling lessons learned–from 0 to 15 million users describes the lessons learned while building a system that has grown to handle up to 15 million users over the last 3 years. It is an excellent read and the lessons can be of use to any who develops systems that need to be able to scale (and even for those that don’t have such a need).
  • Sean Hull’s 20 Obstacles to Scalability addresses some key points to consider, when designing a web application that will need to scale. Although based on a MySQL based web app, the advice is general enough and applicable to any RDBMS based web application.
  • James Turner’s What Developers Can Learn from healthcare.gov addresses some of the issues exhibited by the healthcare.gov website, to draw more general lessons regarding load testing, good looks vs. functionality, and validation, that can be of value to any website. A very good read.
  • Chris Andrè Dale’s Why it’s easy being a hacker – A SQL injection case study, although from last January, addresses the issue of SQL injection vulnerabilities and the fact that many easily available teaching materials used by developers may actually contribute to the persistence of such vulnerabilities. It is a very good read and it draws the attention to one issue that can, indeed, have negative consequences – the  influence of teaching materials on developers and their work. This is an issue that will deserve a future post here.

 That’s it for this week. Thanks for reading.