Rails Recipes: Rails 3 Edition – Solutions to 70 Problems & More – #bookreview #in #rails #programming

Rails Recipes: Rails 3 Edition
Chad Fowler
Pragmatic Bookshelf, paperback, list price $35.00)

Chad Fowler’s Rails Recipes: Rails 3 Edition is aimed at developers who need to solve tough problems while using Rails. But Rails beginners also can learn plenty from the 70 “recipes” in this excellent guide.

The 280-page book is divided into seven parts. Busy Rails developers can jump directly to any part that deals with their latest vexation. Those new to Rails also can read the book in any “recipe” order, or they can take it straight through like a textbook.

The seven parts are:

  1. Database Recipes
  2. Controller Recipes
  3. User Interface Recipes
  4. Testing Recipes
  5. Email Recipes
  6. Big-Picture Recipes
  7. Extending Rails

The author uses a simple problem-solution approach. For example, in Recipe 28, the problem is: “You notice a recurring pattern in your application. You’re writing code for the same actions over and over again in your controllers.” The solution Fowler presents involves learning how to use the Rails versions of macros to create “code that writes codes for you….” by taking “advantage of Ruby’s metaprogramming capabilities.”

He then shows how, noting that “Ruby, like Lisp and Smalltalk before it, allows programmers to easily write code that writes and loads code at runtime.” He adds: “This is a really deep topic, and we’re not going to attempt to dig too deep into it here. Instead, we’ll focus on the details necessary to implement our own Action Controller macros.”

Each recipe spans only a few pages but is presented clearly and is well illustrated with code examples.

Anyone working with Rails or still adding it to their programming capabilities should consider getting Rails Recipes: Rails 3 Edition and keeping it within easy reach.

Si Dunn

Mitt Romney, Secret Keynesian? Read Paul Krugman’s ‘End This Depression Now!’ – #bookreview #in #economics #politics

End This Depression Now!
Paul Krugman
(Norton, hardback, list price $24.95; Kindle edition, list price $24.95)

If you’d like to watch some ultra-right conservatives break out in hives, do a St. Vitus Dance or just spontaneously combust, ask them to read End This Depression Now! by Paul Krugman.

Most of them won’t read it, of course. They will cast it aside or maybe even set it on fire. Their hearts and minds are firmly set in ideology and rhetoric concrete. No matter what Krugman says or writes, they will remain firmly convinced he is a spawn of the Devil or, at the very least, some kind of Communist-Socialist-Liberal-Radical Raider of the Lost Tax Cut.

Actually, Paul Krugman is one of America’s smartest economic smart guys, and he has some very good ideas about how to help America pick itself up–and stay standing–after getting knocked down, hard, and robbed of its wallet by the Great Recession and depression that followed.

I am an unabashed fan of Krugman, winner of a well-deserved Nobel Prize in economics. He makes clear and steady good sense in his New York Times columns, and he makes damned good sense throughout his new book.

“In the Great Depression,” he writes, “leaders had an excuse: nobody really understood what was happening or how to fix it. Today’s leaders don’t have that excuse. We have both the knowledge and the tools to end this suffering.”

We do, indeed, as he demonstrates convincingly in his book. But we also have seemingly intractable political polarization at the very time when our leaders should be gathered in the middle, rapidly hammering out compromises, and actually doing something to help the nation, not just their financial backers and parties.

Krugman lays out many solid strategies, most of them built around growth, not European-style fiscal austerity, particularly in a time of lingering high unemployment, stagnant or falling wages, and tepid consumer spending. And he looks toward the November election with at least a token effort to appear independent and bipartisan. He has, in fact, strongly criticized economic mistakes made by both sides.

If Obama wins, Krugman writes, “obviously it makes it easiest to imagine America doing what it takes to restore full employment. In effect, the Obama administration would get an opportunity at a do-over, taking strong steps it failed to take in 2009. Since Obama is unlikely to have a filibuster-proof majority in the Senate, taking these strong steps would require making use of reconciliation, the procedure that Democrats used to pass health care reform and that Bush used to pass both of his tax cuts. So be it. If nervous advisors warn about the political fallout, Obama should remember the hard-learned lesson of his first term: the best economic strategy from a political point of view is the one that delivers tangible progress.”

On the other hand: “A Romney victory would naturally create a very different situation; if Romney adhered to Republican orthodoxy, he would of course reject any action along the lines I’ve advocated.”

But that’s not all. In Krugman’s view: “It’s not clear, however, whether Romney believes any of the things he is currently saying. His two chief economic advisors, Harvard’s N. Gregory Mankiw and Columbia’s Glenn Hubbard, are committed Republicans but also quite Keynesian in their views about macroeconomics. Indeed, early in the crisis, Mankiw argued for a sharp rise in the Fed’s inflation target, a proposal that was and is anathema to most of his party. His proposal caused the predictable uproar, and he went silent on the issue. But we can at least hope Romney’s inner circle holds views that are much more realistic than anything the candidate says in his speeches, and that once in office he would rip off his mask, revealing his true pragmatic/Keynesian nature.”

To which Krugman adds: “I know, I know, hoping that a politician is in fact a complete fraud who doesn’t believe any of the things he claims to believe is no way to run a great nation. And it’s certainly not reason to vote for that politician!”

The upcoming election is still just a distracting sideshow to what America needs now. We need jobs, spending, revenue, investments in education, and re-training for the long-term unemployed. And, yes, we need for a lot of Krugman-style clear-thinking and common sense to miraculously infect the brains of our economic and political leaders.

Get, read, and heed this book.

Si Dunn

Ride Some Rails with The Rails View – #bookreview #in #rails #programming

The Rails View: Create a Beautiful and Maintainable User Experience
John Athayde and Bruce Williams
(Pragmatic Bookshelf, paperback, list price $35.00)

Rails was created in 2004 “and the web discovered the MVC (model-view-controller) pattern in earnest, which brought a whole new level of productivity and fun to a world of developers and designers,” the authors of this “very ambitious” book declare.

They note that many books “provide a firm foundation for writing controllers and models (which benefit greatly from being written top-to-bottom in plain Ruby), but when it comes to views—that meeting place of Ruby, HTML, JavaScript, and CSS (not to mention developers and designers)—what’s a disciplined craftsman to do?”

Athayde and Williams have written this views-centric book to help “widen the discussion of Rails best practices to include solid, objective principles we can follow when building and refactoring views.”

They add: “Many developers are uneasy around the view layer” and frequently in a hurry to just get out of it, leaving it “easy for the view layer to become a no-man’s land that no one owns or adequately polices or a junkyard that no one feels safe to walk through.”

The 245-page book’s nine chapters are well-written and adequately illustrated with code examples, screen shots and other illustrations, including highlighted tips.

The book follows a structure where chapters build upon the content of the previous chapter. The chapters are:

  • Creating an Application Layout
  • Improving Readability
  • Adding Cascading Style Sheets
  • Adding JavaScript
  • Building Maintainable Forms
  • Using Presenters
  • Handing Mobile Views
  • Working with Email
  • Optimizing Performance

One of the appendices is titled “The Rails View Rules.” It is a handy list of 10 “rules of thumb” when doing development work.

The book is aimed mostly at designers working with Rails and Rails developers working in the view layer. But newcomers curious about Rails or just getting started with Rails can learn from it, too.

The Rails View was built on top of Rails 3.2.1 and Ruby 1.9.3 and should be compatible with future stable releases for quite some time,” the authors say.

If you try to use earlier versions, you may run into some problems, they caution. “Much of the content and code would need to be modified to work with some earlier versions due to our coverage of the Rails 3.1+ asset pipeline and use of the new Ruby 1.9 Hash literal syntax.”

Si Dunn

PHP & MySQL: Novice to Ninja, 5th Ed. – A popular how-to guide updated – #bookreview #in #php #programming

PHP & MySQL: Novice to Ninja, 5th Edition
Kevin Yank
(SitePoint,
paperback, list price $39.95; Kindle edition, list price $29.95)

A key measure of a programming book’s usefulness and popularity is how many times it has been revised and reprinted.

Kevin Yank’s book first was published in 2001 under a different title. Eleven years later, his newly revised fifth edition is now in print and providing up-to-date hands-on guidance for those who want to use PHP and MySQL to create database-driven websites.  (By some estimates, at least 20 million websites worldwide now use PHP.)

Yank points out that “PHP is a server-side scripting language that lets you insert instructions into your web pages that your web server software (in most cases, Apache) will execute before it sends those pages to browsers that request them.”

Meanwhile, “[a] database server (in our case MySQL) is a program that can store large amounts of information in an organized format that’s easily accessible through programming languages like PHP. For example, you could tell PHP to look in the database for a list of jokes that you’d like to appear on your website.”

Yank’s fifth edition shows you how to use PHP to create a working content management system (CMS) that accesses – no surprise here – an online joke database that’s managed with MySQL. (Of course, if you think a simple joke database is lame, you can always modify a few tables and labels and create something more substantial, such as a database of vegetables you hate or celebrities or politicians you consider utterly irrelevant to your life.) 

Building a joke database (or whatever) is a pleasant way to learn the basics of PHP coding and database design and then quickly start improving your knowledge and skills as the CMS project is expanded and given more capabilities.

Yank’s book has 12 chapters and four appendices. The how-to chapters are split into short paragraphs, with numerous short code examples. A link is provided where the book’s code examples can be downloaded in a ZIP archive. And the book’s text is written in a smooth, approachable style.

PHP & MySQL: Novice to Ninja, 5th Edition is “aimed at intermediate and advanced web designers looking to make the leap into server-side programming,” Yank says. He expects readers to be familiar with “simple HTML” but “[n]o knowledge of Cascading Style Sheets (CSS) or JavaScript is assumed or required.”

He adds, however, “if you do know JavaScript, you’ll find it will make learning PHP a breeze, since these languages are quite similar.”

Si Dunn

Android Cookbook: Problems & Solutions for Android Developers – #bookreview #in #programming

Android Cookbook
Edited by Ian F. Darwin
(O’Reilly, paperback, list price $54.99; Kindle edition, list price$43.99)

Several dozen Android developers have contributed some 200 tested “recipes” to this hefty how-to guide for building Android apps.

But be sure you know Java reasonably well before tackling Android Cookbook. As the book’s editor, Ian F. Darwin, notes, “Android apps are written in the Java language before they are converted into Android’s own class file format, DEX. If you don’t know how to program in Java you will find it hard to write Android apps.”

The 661-page book starts at the traditional “Hello, World” level so you can test two different approaches. At the command line, it shows how to “create a new Android project without using the Eclipse ADT plug-in.” And then it shows how to create an Android application using Eclipse.

From there, a clear and simple problem-solution approach is taken, and the solutions are illustrated with code examples.

The 22 chapters cover a wide range:

  1. Getting Started
  2. Designing a Successful Application
  3. Testing
  4. Inter-/Intra-Process Communications
  5. Content Providers
  6. Graphics
  7. Graphical User Interface
  8. GUI Alerts: Menus, Dialogs, Toasts, and Notifications
  9. GUI: ListView
  10. Multimedia
  11. Data Persistence
  12. Telephone Applications
  13. Networked Applications
  14. Gaming and Animation
  15. Social Networking
  16. Location and Map Applications
  17. Accelerometer
  18. Bluetooth
  19. System and Device Control
  20. Other Programming Languages and Frameworks
  21. Strings and Internationalization
  22. Packaging, Deploying, and Distributing/Selling Your App

In Ian Darwin’s view, “Android is ‘the open source revolution’ applied to cellular telephony and mobile computing. At least part of the revolution.”

There have been worries in the past about Android’s future. But Darwin and the book’s contributors are among the many who remain firmly convinced that “Android is definitely here to stay!” Darwin adds: “This book is here to help the Android developer community share the knowledge that will make it happen.”

Si Dunn

Programming Clojure, 2nd Edition – The virtues of concurrency and functional style – #bookreview #in #programming

Programming Clojure, 2nd Edition
Stuart Halloway and Aaron Bedra
(Pragmatic Bookshelf,
paperback, list price $35.00)

Clojure is yet another computer programming language with an odd name and many followers.

For example, Dr. Venkat Subramaniam, an award-winning author and founder of Agile Developer, Inc., has called Clojure “a beautiful, elegant, and very powerful language on the JVM [Java Virtual Machine].”

A lot has happened to Clojure (pronounced like “closure”) since the first edition of this book was published in 2009. Clojure has been updated several times and gained some enhancements, a lot of new followers, and many libraries.

Programming Clojure, 2nd Edition has been rewritten and reorganized to cover these new features, concepts and developments.

“Clojure is a powerful, general-purpose programming language,” the authors note. But this is not a book for raw beginners, even though its first chapter does start at the traditional “Hello, world” level. It is intended for “experienced programmers looking for power and elegance.” You should have some experience with C#, Java, Python, or Ruby before tackling Clojure.

“Clojure is built on top of the Java Virtual Machine, and it is fast,” Halloway and Bedra emphasize. “This book will be of interest of Java programmers who want the expressiveness of a dynamic language without compromising on performance.”

They add: “If you program in Lisp, use a functional language such as Haskell, or write explicitly concurrent programs, you will enjoy Clojure.”

Indeed, Clojure’s creator, Rick Hickey, emphasizes the language’s value as an alternative to the “complexity” introduced in object-oriented programming. “Object-oriented programming seems easy,” he states, “but the programs it yields can often be complex webs of interconnected mutable objects.”

He continues: “Functional programming offers an alternative. By emphasizing pure functions that take and return immutable values, it makes side effects the exception rather than the norm. Clojure is designed to make functional programming approachable and practical for commercial software developers.”

Clojure also makes concurrent programming easier. “Many languages build a concurrency model around locking, which is difficult to use correctly,” the authors point out. “Clojure provides several alternatives to locking: software transactional memory, agents, atoms, and dynamic variables.”

The 268-page book is well-organized and well written, and it offers numerous practical code examples. The book also has been reviewed for technical accuracy by a panel of Clojure practitioners.

Clojure code, incidentally, tends to be short (but you do need an editor that can “at least indent code correctly and can match parentheses”).

In one of the book’s comparison examples, the function produced by a 14-line sample of Java code is duplicated in Clojure with just two lines. So development in Clojure potentially can be fast.

Si Dunn

The CSS3 Anthology: Take Your Sites to New Heights – #bookreview #in #webdesign

The CSS3 Anthology: Take Your Sites to New Heights, 4th Edition
Rachel Andrew
(SitePoint,
paperback, list price $39.95; Kindle edition, list price $29.95)

“The basic purpose of CSS [Cascading Style Sheets],” Rachel Andrew notes, “is to allow the [web] designer to define style declarations — formatting details such as fonts, element sizes, and colors — and then apply those styles to selected portions of HTML pages using selectors: references to an element or group of elements to which the style is applied.”

The fourth edition of this popular how-to book for Cascading Style Sheets is aimed at providing how-to examples, shortcuts and tips for busy web designers and web developers already working with CSS.

However, web-savvy beginners and those who build and maintain their own websites also can benefit from this well-written book. Along with a short introduction to CSS basics, it offers many short code examples and related screenshots. And virtually every chapter is structured around answering the question “How do I…?” as each new topic is introduced.

Indeed, the 420-page book is a compilation of answers to questions, specific how-tos and examples readily adaptable to real-world web pages.

The CSS3 Anthology is organized into nine chapters:

  • Making a Quick Start with CSS
  • Text Styling and Other Basics
  • Images and Other Design Elements
  • Navigation
  • Tabular Data
  • Forms and User Interfaces
  • Cross-browser Techniques
  • CSS Positioning Basics
  • CSS for Layout

If you need a tutorial or refresher in HTML and CSS basics before grabbing this book, the author recommends Build Your Own Website the Right Way Using HTML & CSS, 3rd Edition, available in paperback and ebook formats.

— Si Dunn

#