Beginning Backbone: My First Book

BookCoverIt’s been a long time ambition of mine to write a technical book. In the second half of 2013, I finally got the opportunity to do that, publishing Beginning Backbone.js with Apress. The book is available to purchase now, in all the usual formats.

Read (or scroll, but I’d prefer you read!) to the end of this post to get an excellent 30% off the ebook price until January 23)

Who’s The Book For? Everyone

When planning this book, I had a number of different readers in mind. As such, I feel that I’ve written this book to appeal across the board. JavaScript novices will find the book useful, as it starts at the simplest level. At the same time, experts should find this to be an excellent way to learn Backbone inside out.

I also wanted this book to appeal to CTOs, who are hearing that Backbone is (or isn’t) the next best thing for their web app: this book will help them form their own opinion. Finally, the book will assist teams who are getting to grips with large scale JavaScript application development.  With chapters covering test driven development, best practices and continuous integration, the book shows the level of maturity that JavaScript has reached.

What’s Backbone?  

At this point, I’m sure most people have heard about Backbone, a library that helps organise your JavaScript code in a structured Model View * format. The thing that I like most about Backbone is that it is un-opinionated, unlike Angular and Meteor. While this results in the developer needing to write more boilerplate code, it gives a very comfortable level of control. More about this later, as it is one of the most contentious issues in JavaScript framework selection these days.

What’s in the Book?

There are a number of different sections in the book that deal with different issues.

The Introductory Section

The first two chapters are designed to ease the reader into the web application development world. This first group of chapters introduce Backbone and similar libraries, along with going back-to-basics on object oriented JavaScript. If you’re rusty,it’s worth reading through this chapter to strengthen your understanding of what the language provides before diving into the library itself.

The Nuts & Bolts Section 

The next batch of three chapters bring in the main concepts that exist in Backbone: Models, Collections, Views, Routers and Events. When going through the code examples in these chapters, a node.js server is used to provide a  REST API. While the depth in which node.js is explored is limited, I feel this a bonus for front-end developers. Each of these chapters iterates from the simplest possible version and then shows how additional configuration add more power.

I am particularly proud of the chapter that discusses Backbone Views. In true un-opinionated fashion, I explain how to use three of the leading template libraries for your views: Underscore, Handlebars and Mustache. Using a template library means that you get to avoid polluting your JavaScript with HTML strings. All three libraries listed have their own brilliances, but I find it difficult to beat Handlebars.

With this knowledge, Chapter 6 goes from start to finish with a complete application example. For this I went with Twitter, as it provides an easily understandable API. This gives the opportunity to use a Models, Collections, Routers and many different views on a single page. You end up with something that looks like the picture below.

app

The Extending Backbone Section

From the point, the book changes tone slightly. First I take a look at the huge number of extensions that have been written by the Backbone developer community. Here’s where the naysayers should look, if they feel that Backbones lack of data-view binding is hampering their progress. There are extensions available to help you out of almost any problem that you feel Backbone has. The beauty of this is that you can easily integrate most of these plugins in your Backbone applications. And it’s just as simple to take them out.

Similar to this chapter, Chapter 10 looks at Backbone Marionette and Thorax. These are amazing additions to Backbone, and deserved their own chapter. To put both through their paces, the Twitter sample application is refactored to utilise the features they provide.

The Discipline Section

With all this code, you’re going to need some discipline. That’s where the test driven development chapter will help. The most popular JavaScript testing frameworks out there are Jasmine and QUnit, so these are both described in detail, illustrating how to test out that sample Twitter application.

The next chapter shows how to use Grunt to add continuous integration to your JavaScript development. Grunt is an amazingly powerful tool that no JavaScript developer should be without. As a developer who has come from the Java world, it’s great to see something that easily surpasses the power of Maven or Ant.

The Doing-It-Better Section

For anyone who is already using Backbone, the chapter on best practices will help them to improve on what they already know. These tips were gathered from a wide variety of sources, as well as from my own experiences. Then the book closes out with tips on making your code even more manageable by using Require.js to created a modular codebase.

That final chapter also shows how to use the amazing Yeoman when you need to start from scratch in your development. The Backbone generator that’s included is brilliant. And once you discover the starting point that Yeoman provides, you’ll never look back.

So, In Summary

As you can see, while to book focuses on Backbone as the core topic, it extends much further. It’s a book that covers everything that you need to know about using JavaScript, along with Backbone, in a professional software development environment. I really hope you do enjoy reading it, and using anything that you learn, as much as I enjoyed writing it.

If you like the sound of this, why not buy the book. Or how about this:  I can give you 30% off the price of the ebook if you purchase the book from the Apress site using the code BCKJ14.  
 
BookCover

Introducing donate:code

Over the past few months, I’ve been working on building up a foundation that aims to help charities and community groups to gain access to software developers and designers in order to build websites, apps and help  out with technical issues they have. Today being Thanksgiving Day in the US seems to be a fitting time to announce the project, so I’d like to introduce donate:code.

Screen Shot 2013-11-28 at 07.18.34The idea behind donate:code is simple and obvious.  Every charity, school and community group has technology needs. Sometimes it’s a simple website update, or perhaps they need help getting a social network up and running. How about more ambitious charities who want to build an app to generate some extra revenue? There’s just one problem – the cost of getting someone with the technical skills to help. Wouldn’t it be great if someone could donate their time?

Software developers, web and graphic designers excel in their fields. But they know that to be better, they need more experience. Instead of putting time into side projects that go nowhere, why not donate time and expertise to some group that really needs your help. Increase your portfolio, and gain some extra karma while you do. Learn how to work with diverse customers, and make your CV stand out.

Before launching this, I wanted to test the viability of the idea. In doing this I’ve worked on two projects. Firstly, I built Signalong Songs for the Cope Foundation. This is an interactive iPad app that teaches children how to sign along with their favourite nursery rhymes. I didn’t charge a cent for the development of the app, instead requesting that what the charity had budgeted for the app be put to good use in the charity. It proved to me that money wasn’t everything. And it was a fantastic way to give back to charity. I felt that I was onto something.

I also helped out another local charity group in creating a community website for autism awareness. The people behind this charity are true heroes, and it felt great to be able to help them get up and running with a WordPress site that is easy for the Karen, Jon and other volunteers to get news on their fund raising events out, and also to provide support to people affected by autism.

Over the course of building the app and website, along with the site for donate:code itself, I found that there are always people out their willing to help. I managed to get support for the hosting of donate:code, and someone else volunteered their server for another of the projects.  It has encouraged me to reach out further. 

If you’re a developer or designer who likes the  idea of giving, just head on over to donate:code and use the contact form there to volunteer. As much as we need the technical people, we also need the projects to work on: charities and schools, if your budget has prevented you for building the app or website that would make a difference, please contact us too.

 

Instant Dependency Management with RequireJS

Dependency Management with RequireJSGreg Franko has put together a really concise, useful book on RequireJS. Weighing in at just 29 pages, this book is not too demanding on your time. Don’t let that discourage you; the knowledge you’ll pick up is indispensible.

The book caters for developers who are already familiar with RequireJS, as well as complete newbies. You’ll be shown how to setup a simple RequireJS configuration for your web application and shown how it works in the background.

From there, you’ll be show how to create AMD modules to use with RequireJS, before moving onto the best parts of the book, showing how to use JQuery and Backbone with RequireJS.

What might interest most developers, however, is the application of the DRY (Don’t Repeat Yourself) development principle when developing desktop and mobile web logic. Greg provides a recipe that will make this trivial for you to implement for your project.
Although short, this book is incredibly effective and gets the point with surgical precision. If you’re serious about your JavaScript code base, you’ll want this e-book.

 

Use Chrome as Your JavaScript IDE

Earlier this week I attended FOWD, a fantastic conference for web designers and developers in the heart of London.  One of the highlights of the trip was the JavaScript Web Warrior workshop with Addy Osmani. He mentioned  that using Chrome Experiments you could edit your JavaScript right there in Chrome, without needing to bother with any other editors. Here’s how to enable that feature:

  • Download Chrome Canary. Standard Chrome doesn’t have this feature yet, so it’s time to live on the edge. Of course, Canary can be installed alongside Chrome without any issues, so it’s cool. 
  • From Canary, navigate to chrome://flags and enable the Developer Tool Experiments
    Screen Shot 2013-05-17 at 09.54.43
  • Restart Canary and then navigate to the site, hosted locally, that you want to work with.
  • Open up Chrome Dev Tools, and click on the settings cog. From here, navigate to the Workspace section.
    This is where you can set up the mappings from URL to file system. Screen Shot 2013-05-18 at 09.05.36

Obviously you will need to give Chrome access to your filesystem.

 

And that’s it – you’re good to go.

In the following video, Addy gives a run down on how to use this workspaces feature:

Shipping Greatness: Book Review

Something every developer and team aspires to is shipping great software. But as we all know, it doesn’t always work out that way. So what can we learn from Chris Vander Mey’s Shipping Greatness ? 

First, let’s take a look at the authors credentials; Chris has worked as a product manager at Google and an engineering manager at Amazon; two companies who have a pretty good track record when it comes to delivering products. So, I guess he has learned a thing or two.

The book is split into two parts. The first focusses on the step by step shipping process that the author has seen used in Google and Amazon.  This starts with defining your misson, puts a spotlight on creating a great user experience and deals with the testing and measurement of your delivery.

The second part of the book looks at the best practices and techniques that you should use as someone trying to orchestrate a great delivery.  Skills that you will read about in this section include how to build a team that is up to the task, and how to be a great communicator and decision maker.

While the book will appeal to anyone who wants to build great, meaningful software products, it is probably managers and technical leads that will get the most out of Shipping Greatness. 

There’s a really nice “10 Principles of Shipping” list at the back of the book, which any leader should keep in mind – maybe put a printout up on the team whiteboard. These principles include tips such as  ”start with the user and work outward” or “you’ll never do the whole job, so first od that which only you can do”.  As well as showing the way to deliver greatness, this book could help improve how you lead your team.

Running Lean: Book Review

If you want to execute lean practices at your startup, then Running Lean   by Ash Maurya should be top of your reading list.  Highly regarded by reviewers across the board, the book claims to help you to Iterate from Plan A to a Plan That Works. So how does it do that?

The book is broken into four distinct parts. First, you are introduced to a roadmap of how to apply the process, which is made up of three meta-principles: document your plan A, identify the riskiest parts of your plan, and then, systematically test your plan.  For software developers familiar with agile processes, this may sound familiar. But don’t let that stop you from learning how to apply these principles.

I claim to understand lean/agile and any other buzzword that claims to get the right product out quickly. But understanding and execution are two entirely different things. Ash does a fantastic job of explaining the intricacies of each of these steps. Even the documenting of your plan A gives some great tips on working out what your business model should be, what to prioritise and how to track progress.

The part that gets most focus in the book is the testing of your plan, where you need to go through the steps of understanding the problem, defining the solution and validating the solution.

As a software developer, this book made me realise the value in a defined iterative process. As someone who’d like to create my own company, this book provides a useful handbook for the early days of a startup.

Gradle Effective Implementation Guide: Book Review

Until recently, Ant has been my build system of choice: functional, proven and, it just works. So, I was intrigued to see what Gradle could provide instead. So when Hubert Klein Ikkink , one of DZone’s leading MVBs on Groovy, gave me the chance to review his Gradle Effective Implementation Guide , I could hardly refuse.

The book begins with a really good introduction into what Gradle actually is. Useful for Gradle newbies like me, but most people can probably afford to skip it.  The book then goes through the main things you’ll want to do in your Gradle build scripts; using tasks and dealing with files and directories; before showing how easy it is to use Gradle for your Java projects. Later on the book illustrates how you can use the Scala or Groovy plugins to build projects for those languages, and how to build multiple projects that are dependent on each other.

I found the chapter on writing custom tasks and plugins to be particularly useful. Most importantly, the author explains how you can write tests for your custom plugins to ensure they work as expected. As you’d expect, Gradle has good IDE and continuous integration support, all of which is explained in the last chapters.

The book will probably appeal more to people who are new to Gradle. I found the explanations to be be really detailed and useful. Whether I’ll use Gradle for my next project, I’m not sure – but it certainly is tempting

How To Be The Next Big Thing

Everyone wants to be the next big thing, but few of us are fortunate enough to know where to start. Luckily, Paul Graham gave some insight into this in his latest post, How To Get Startup Ideas.

There’s one piece of advice that keeps coming up, whether it’s in this latest post from Paul, or the Steve Jobs biography - build something that you would want to have.  At least this way you have a customer from day 1, right?

Another benefit of “you being the customer” is that you know exactly what the problem is – no need to spend time testing markets early on. Sometimes testing the market means asking friends and family whether they would find a particular idea useful. That’s ok, but bear in mind that it takes a strong friend to tell you that your idea sucks.

These days there is more and more pressure on people in software to come up with great ideas. But this pressure just ends up in below-par products, or worse, products that no one wants:

Why do so many founders build things no one wants? Because they begin by trying to think of startup ideas. That m.o. is doubly dangerous: it doesn’t merely yield few good ideas; it yields bad ideas that sound plausible enough to fool you into working on them.

Paul mentions one more point that resonates with me – thinking that the idea is too late, that someone has already done it, and that I should just force myself to think up something different, leaving a perfectly good idea behind

Because a good idea should seem obvious, when you have one you’ll tend to feel that you’re late. Don’t let that deter you. Worrying that you’re late is one of the signs of a good idea. Ten minutes of searching the web will usually settle the question. Even if you find someone else working on the same thing, you’re probably not too late.

How many times has this been proven over the last three decades? IBM has the PC industry sewn up and along came Apple. Altavista was a great search engine (in it’s time) and now we all use Google. The MP3 player market was flooded, and the iPod became the default.

It’s never too late to disrupt, you just need to believe in your idea.

 

 

Facebook Compiling PHP to Run on the JVM?

An article popped up today claiming that Facebook is investigating compiling PHP to run on the JVM. Until now, Facebook has been using a PHP-to-C++ cross compiler. But the addition of invoke dynamic to Java seems to have opened up a new possibility for Facebook.

Alexander Turner, the author of this article points out that using the Multi Language VM for PHP is somewhat analogous to what V8 has done for JavaScript: JIT compilation of interpreted languages shows a significant increase in speed. In fact, Alexander sees this as the beginning of the end for interpreters:

These are exciting times. Soon I expect interpretors and interpreted langauges to be confined to DSLs and all general-purpose coding to be running in a JIT environment or as up-front compilation. That will be good for companies, good for performance and good for the planet.

Either way, it’s good to see another of the major companies taking the JVM seriously. It could certainly take a long time for Facebook to get to a stage where they can have their code running on a VM unless they leverage the Quercus or Project Zero implementations.

Unknown is whether this is actually happening, but it brings up an interesting debate. If you had a Facebook-size codebase written in PHP, would you take this approach? Node.js would certainly be a more fashionable alternative.

The Most Popular Language This Month Is….

The most popular language of this month? Well it depends which source you use. For example, I checked out the TIOBE index as well as the top language used in GitHub projects. Would you be surprised that Java was not number 1 on either listing?

Now, I never take these language popularity things too seriously. More than likely, the language you’re using at work isn’t the cool language of the day. But it gives a good indication of what languages might be worth learning, if you have the time.

TIOBE Index – C Reigns Supreme

On the TIOBE index, where Java has been number one for a very very long time, C has taken it’s place at the top. Yes, C!

Don’t worry if you’re confused right now looking at this – I don’t get it either! It’s obvious that Objective-C continues to grow more popular. But JavaScript looks a bit low on this index, especially when you consider the results I found at GitHub

GitHub  – Everybody Loves JavaScript

I guess the GitHub ratings make more sense, considering you can’t move in GitHub without bumping into a JavaScript project. Every other language has a reasonable showing. Compare Java to C and there’s not much in it.

Some Better News For Java Developers

I didn’t have to go too far to find some good news for Java developers. RoleConnect, an Irish company that connects contractors with employers ran some analysis on what skills are most in demand right now. According to the team there, there’s still a huge interest in Java/J2EE and Spring developers.

So, three different indices and it’s no clearer what the most popular language really is. Is there a definitive way to measure this statistic? Or is it just all too subjective?