Posts tagged apress

Book Review: Practical Reporting with Ruby and Rails

Practical Reporting with Ruby and Rails is primarily a book about the presentation of reports. Having gone in expecting a mixture of presentation and production techniques I was a little surprised to find that the vast majority of the reader’s time is spent looking at various GUI and graphing toolkits, export to MS Office and the like, and there’s not much space given to managing large volumes of data, warehousing, and other such topics.

That’s not a criticism of the book so much as a caution to potential readers. After a little time spent looking at ActiveRecord, particularly focussing on using its calculation methods to save processor time, David Berube provides a pretty thorough coverage of a variety of ways to present reports. A few options for delivering data as PDFs, through a GUI, or directly into office are offered and a straightforward walkthrough is provided for each. The Rails content is minimal, and while the sample code could do with some refactoring and there’d be a case for using something more lightweight like merb it does the job.

But I must confess to being a little disappointed that there wasn’t more time spent on the data processing side of the equation. Having been building a lot of graphs lately and needing to write some new reporting code in the near future it was helpful to have some analysis of tools I might use, but I never felt like the book ever really dove into the complexities of reporting. There’s space in a book of this sort for serious consideration of both data processing and of visualisation techniques, but neither is really offered. Each chapter simply answers a very tightly defined request rather than delving into the full problem domain, and that feels like a missed opportunity.

If you’re evaluating output options for your ruby application’s reporting layer, this may be a handy book to have. It’ll provide you with a sense of what tools are appropriate for which problems and more detailed sample code than is easily found on the web. But if you’re looking to really grapple with reporting and visualisation you might be better off seeking out a good SQL reference and some of Tufte’s books.

Disclaimer: I was sent a copy of this book for review by the publisher. You can find it at apress, amazon US, amazon UK and all sorts of other places.

Book Review: The Definitive Guide to Django

Book Sleeve: The Definitive Guide to DjangoDjango is a framework I’ve long (in web years) held in some esteem, despite never having used it before the past few weeks. The framework’s creators’ many well reasoned contributions on all manner of debates about the web suggested a thoughtful approach, and the range of high quality sites powered by Django has kept growing, with the recent launch of EveryBlock being a prime example of its capabilities. So I was delighted to receive a copy of The Definitive Guide to django: Web Development Done Right for review.

Authored by two of the creators of Django: Adrian Holovaty and Jacob Kaplan-Moss, the book is carefully structured, initially placing django in context by exploring various approaches to web development, and then stepping through initial project creation, templates, models, url configuration, django’s famed admin interface, and so on. After eight chapters it changes tack and switches from basic tutorial to more in-depth exploration of areas like the ORM, session handling, caching and deployment. Several appendices provide supplementary material.

The first few chapters do a good job of laying out the foci of the framework’s architecture and it’s Model Template View (MTV) approach. Its pace is measured and while I wonder if it might be a little too much too soon for those totally new to full stack web frameworks, it would work well for those coming from a background building web apps with PHP, Java, or for those of us who are used to working with Rails. There are new techniques to learn and I found the book particularly useful for grasping the deeply pythonic approach, favouring flexibility over convention.

A clear example of that comes in the use of Context objects for passing values between Views and Templates. The authors initially show us the most verbose and rudimentary way to do it and gradually develop that to show how they’ve provided for various common cases. By going through those steps there’s a good chance the reader will be well equipped to work out ways to simplify their own workflow and/or create new subclasses to promote reuse in their code.

Where the book is lacking is in the examples. The introductory material, and much of the reference content is excellent, but as a newcomer to the framework I felt a little lost in how I should structure my code and how different components relate; it’s clear how models relate to the database, but how do I pass them around when building associations?

I recognise that django deliberately avoids the strong conventions of the Rails community (though even there you frequently find newcomers unsure where in the directory structure to place certain components) and there’s no need for lengthy tutorials on building a shop or how a magazine cms could work, but when I come to a book like this I’m looking for a guide to best practices at the project architecture level, not just the component level, and I was sorry not to find it. The authors clearly have a lot of experience of structuring django sites of all shapes and sizes and it would be good to learn more about how they keep those sites organised.

That said, this is a solid introduction to django for web developers; a solid contribution in a so-far underserved market and it’s likely to come in handy for a number of people. Just be prepared to supplement it with a fair amount of time in search engines working out good strategies for connecting the pieces.

Disclaimer: I was sent a copy of this book for review by the publisher. You can read it for free online or find it at apress, amazon US, amazon UK and all sorts of other places.

Book Review: Practical Ruby Projects

Practical Ruby Projects book sleeveThe past few years have seen the English-language Ruby book market explode. Before the phenomenal success of Rails it was perfectly possible to own every available title (and not use much storage space), but now that would be quite a challenge and lead to considerable redundancy. Having worked my way through quite a few Rails books of late, reading Practical Ruby Projects—a Ruby book that doesn’t even mention web frameworks—was both a pleasant diversion and a highly illuminating experience.

Like the last volume I reviewed, this book is unabashedly aimed at experienced programmers. There’s a brief paragraph on “getting set up”, but no detailed guide to obtaining the tools. Instead we dive right in to a sequence of projects that includes: making music (dipping into calling C code from ruby), animation, simulation, building a strategy game (and adding a RubyCocoa frontend), genetic algorithms, and even implementing lisp and parsers. Once again the “apress roadmap,” a diagram intended to show how the skillsets in their different volumes build on one another, is misleading pitching this between “Beginning Ruby” and other volumes I’ve reviewed like Practical Ruby for System Administration and Pro Active Record. Don’t believe it. Though there’s little overlap in the material, this is a more advanced volume than either of those and readers should be prepared.

The pace of the book is measured and Topher Cyll does a good job of gradually building up the projects a step at a time. Along the way a variety of practices are demonstrated with many methods stubbed out for demonstration purposes before being filled in when they are needed, and considerable time spent on decoupling code. That latter piece is particularly in evidence in the chapters on building a turn-based strategy game and then developing a RubyCocoa front-end. Despite careful design early on further refactoring is needed to make it easy to apply the front-end and that process is carefully worked through.

Most of the book makes some use of existing libraries. The initial lisp chapter uses the sexp library and the subsequent section on writing a parse relies on rparsec. For the most part, however, use of the libraries is kept to a minimum, allowing for fairly self-contained code. Unit testing is largely ignored until the last chapter, where the need for tests when constructing a grammar/parser is explained and a test-first development model is encouraged. That works well to demonstrate the power of tests for complex (and often brittle) code.

This is not a book designed for public transport reading. Working through chapters on the bus I frequently found myself wanting to reach for my laptop to get a better grasp of how a piece of code worked. While the explanation is generally very good, with material of this complexity there is nothing like running the code and tweaking it to make sure you’ve understood exactly what each transformation does. It’s a book to take your time over, so be prepared!

A few editorial errors have crept in, suggesting a re-organisation of the contents late in the day. In particular an early reference to s-expressions seemed to presume that the lisp and/or parsing chapters were featured early. That’s not a big deal and will hopefully be corrected in later printings; the author does encourage skipping around within the book, but there is value in working through it roughly in order, and not just for the two “paired” chapters that explicitly build on one another.

Perhaps the most striking thing about this book is the reminder that even for those of us whose primary programming activity is web development, studying other areas can be extremely helpful. Not only is it helpful to see how other developers structure their code, but tools like genetic algorithms and parsers are likely to be very helpful where web applications require sophisticated processing and/or backend systems. And it never hurts to learn a little lisp. For the ruby developer who’s comfortable with the language and wants to stretch out a little, this book would be an excellent investment.

Disclaimer: I was sent a copy of this book for review by the publisher. You can find it at apress, amazon US, amazon UK and all sorts of other places. Pat Eyler’s review can be found here.

Book Review: Pro Javascript Design Patterns

Pro Javascript Design Patterns sleeveAccording to wikipedia:

In software engineering, a design pattern is a general repeatable solution to a commonly occurring problem in software design. A design pattern is not a finished design that can be transformed directly into code. It is a description or template for how to solve a problem that can be used in many different situations. Object-oriented design patterns typically show relationships and interactions between classes or objects, without specifying the final application classes or objects that are involved. Algorithms are not thought of as design patterns, since they solve computational problems rather than design problems.

Design patterns, and particularly their application in dynamic languages can be a controversial topic, and every now and again another round of blog posts bubbles up appalled at the way a new group of programmers have become infatuated with design patterns. Applied without care design patterns can quickly lead to over-engineered code that seems designed as much to draw on as many of the established patterns as possible as to solve the intended problem. But if applied with care, and with consideration of how a pattern applies in the context of your chosen language they can be a helpful way to draw on the wisdom of the coders that came before you, and make your code easier to understand to those who may inherit it.

Written by Dustin Diaz (of Google) and Ross Harmes (of Yahoo), Pro Javascript Design Patterns builds on experience of building complex, high profile javascript applications. That experience shows as each pattern is introduced with solid examples and sample code and then refined to provide looser-coupling, more flexibility and/or better performance.

Early on in the book I was concerned that some of the solutions could become too heavy and the early introduction of interfaces hinted at something akin to the early approaches to pattern usage in PHP, which often looked more like an attempt to turn PHP into Java than a way to use PHP’s own features better. As the book goes on the usefulness of those interfaces, particularly for large development teams, becomes clear and most of those concerns are allayed, especially as the authors offer pros and cons for the use of each pattern and are clearly focussed on how these patterns can help produce more robust solutions.

Most of the patterns will have a fairly immediate impact for developers new to them, and even for those who have used them in other contexts it is helpful to see how they have been applied in JavaScript. Most modern JavaScript libraries rely on several of these patterns to abstract out handling of different browser quirks or adding new event types, and even if you rely heavily on one or more of the major libraries this guide may well help you understand their internals better.

I’ve sometimes been skeptical about books claiming to be targeted at an advanced target. Labels like “pro” are often handed out far too easily. But in this case it seems deserved. While the book does a good job of quickly introducing approaches to object-oriented programming in JavaScript, that’s based on an assumption of a solid knowledge of the language and of OO development in at least one language. If you’re a newcomer to JavaScript or just looking for a way to add a few fancy features to your web pages this isn’t be book for you. But if you have some serious JavaScript development experience and are needing a way to tighten up your code to make it more modular and more maintainable, this book is well worth your time.

Disclaimer: I was sent a copy of this book for review by the publisher. You can find it at apress, amazon US, amazon UK and all sorts of other places.

Book Review: Practical Ruby Gems

Practical Ruby Gems sleeveFor those who aren’t aware, ruby gems refers a way of packaging up code so it can be easily distributed for other developers to use, and a tool to help with the distributing and/or installing that code. Find out more at wikipedia.

On first glancing at this book, I wondered how you could fill a full-length book on the topic of gems. While getting the tools installed on some systems requires care, and there’s space for a couple of chapters on packaging your own libraries as gems, both topics have been covered alongside other topics in numerous volumes. What I’d missed was that contents not only covers both of those topics, but also looks at 26 different gems and explains how you might use them in your projects.

The coverage of setting up and using ruby gems at the start of the book, and on packaging and distributing your own gems at the end of the book are brief but cover the basics well enough. It might have been helpful had the latter included a little information on how to include other libraries that need to be compiled and managing the cross-platform issues that raises. Chances are anyone planning to do that is well capable of reverse-engineering a gem spec file to work out what’s needed, but it would have added some weight and helped these chapters stand out from their equivalents in other volumes.

The gems profiled cover a wide range of uses: databases, certain web services, parsing HTML, web frameworks, recurring events, PDF generation, and more. Most of them are pretty well known libraries, but few of us will have had a chance to try them all out and newcomers to the ruby community looking for some support in their projects may well find some useful tips within.

For each gem there is an introduction, some basic code samples, a lengthier code sample (with commentary) and conclusion. That repetition means this isn’t a book many will want to wade through in one go. I found that after a while I needed a break, and if reading the book it may be best to pick out a gem that particularly interests you, read the relevant section and then write some code of your own before moving on to another.

A number of times I wondered if it would be preferable to drop some of the best known gems (there are plenty of ActiveRecord examples floating around) in favour of a little more depth. In particular it would have been interesting to see a dissection of how a few of the gems work, as a sign that anyone can contribute, to see what can be learned from techniques used, and to better understand how the gems in question can be used. Such explorations might serve to break up the text a bit, as well as providing useful insights into ruby development and perhaps broadening the appeal of the book a little.

Overall, Practical Ruby Gems was a helpful read and there are a few new gems I’m going to be exploring as a result of my reading, but you may well want to take a close look before investing in a copy. You may broaden your ruby knowledge in the reading, but you’re unlikely to deepen it significantly.

Disclaimer: I was sent a copy of this book for review by the publisher. You can find it at apress, amazon US, amazon UK and all sorts of other places.