Category Archives: Development

You should never publish a blog post on the day you write it

This is something I am continually guilty of, writing something, giving it a quick read over and then immediately posting it up. This isn’t a good idea and it leads to lower quality content being produced and potentially ill conceived ideas being aired.

Obviously in some situations there is an advantage to being first to market, and this applies to blog posts as well. If you are writing about some form of breaking news or writing a ‘live blog’ about something then it would make good sense to ignore this post, but for most other types of writing I think you would benefit from taking a break between writing and publishing.

There are several reasons for this;

  • During the time you finish writing and the time you publish you might come up with a new idea or angle to explore in the post.
  • Grammatical and spelling errors are easier to pick up with fresh eyes.
  • Social media along with sites like Reddit and Hacker News mean your post could be being seen by thousands of people within minutes, so you don’t have the luxury of making small incremental changes after you post.
  • You might think of better wording for something or a more eloquent way to write it.

I have read some people like to wait a week or more before revisiting a body work, I have done this before but I haven’t found that any more effective than just leaving it for a day or two. Your mileage may vary.

It also helps to steady your output, I for one have this massive creative surge for writing at around 11PM at night, depending on the length of the post I could have it written and proof-read by midnight, even if it was good to go and I didn’t think anything could be added it to this would not a good time to post, holding off means I have content that I can share at more opportune times.

Share this on

Review: jQuery HotShot

jQuery HotshotsI have followed and been a fan of Dan Wellman’s writing for some time and when I noticed he was asking on Twitter for people to review a new book he was writing I jumped at the chance.

I have been using jQuery for several years now on a mixture of commercial and personal websites and on various web applications and whilst I don’t always think it is the right solution for a problem, when a library is the right solution jQuery is one of the best. In my current role we heavily use jQuery so I believe I am qualified to accurately review this book.

For this review I am reading the Kindle version of jQuery HotShot which you can buy now from Packt and from Amazon, the book is also available as a paperback for all you cave-people.

jQuery HotShot

So, is jQuery HotShot a good read? Or does Dan fall into the trap that so many jQuery writers do and leave you with pages of poorly written jQuery that doesn’t conform to any best practice?

I am happy to report that true to form Dan has produced an excellent book that manages to explain some of the core features of the library in interesting and memorable ways. He has greatly increased my understanding of some of the features that make jQuery an excellent library.

With hardly any preamble we are thrown straight into a fun example of using jQuery to create a sliding puzzle game. The example manages to assume no prior knowledge but at the same time doesn’t bore someone with prior knowledge by walking at a snails pace, as the book continues the examples get more and more involved.

One of the reasons that jQuery HotShot is able to get straight into good examples is that the examples themselves are littered with little best practice tidbits, for example;

Joining an array of substrings to form a single string is much faster than building a string using the + operator on substrings, and as we’re working repetitively inside a loop, we should optimize the code within the loop as much as possible.

Without needing a chapter or section dedicated to optimisations we have been able to find out about the need to take care about what we do inside loops and also learn a quick performance tips when dealing with strings. This certainly doesn’t have any direct bearing on the task at hand, but helps point the reader towards the best way of doing things.

My favourite example used in the book is probably the Bounty Hunter mobile site that hooks into StackOverflow looking for questions to answer, but the book covers a wide range of examples including building browser add-ons using jQuery and how to build your own jQuery (which introduces things like grunt.js, node.js, git etc.).

I am kind of cheating, because I was already aware of Dan’s writing and work so I knew that he knows his stuff, but you honestly do get the impression that a real expert in their field is writing this book, the way the information is presented shows that he has a deep and broad understanding of the subject material.

Something that I loved but that some might not was how involved the examples were, by this I mean that you could tell the feature or features an example was trying to explain and there are far more concise examples that could have been used, but they would either not have been as fun or wouldn’t have had a grounding in the real world.

One small niggle I have with the book is that the terminology for the sections within a chapter don’t suit my personality, subtitles like “Prepare for Lift Off” and “Engage Thrusters” belong more in the fluffy self-help books I love to read as opposed to a technical book, but I am fully aware the majority of people probably love that kind of stuff! Another tiny irk is that one of the examples talks about infinite scrolling, and I personally think that infinite scrolling is the devil!

My Conclusions

All in all I thoroughly enjoyed this book, and as someone who has been using jQuery in anger for a very long time I did come away haven’t learnt a truck load and I imagine you will too. One day I might write a blog post about the things I have learned from this book, in the mean time you should just go ahead and buy it!

jQuery HotShot Resources

Here are some resources you might find useful related to this review;

Share this on

Web Developer Equipment

In this post I am going to talk about what I feel are the pros and cons between either always having the best of the best or sticking to the old hardware that you know and love. If you have an opinion one way or another please let me know on Twitter, or there are comment threads on both Reddit and Hacker News, if you enjoy this post I would appreciate a quick upvote or a share.

Do you believe that in order to produce great work in large quantities you need great kit?

This isn’t a leading question, I am genuinely interested and it is something I to-and-fro on fairly regularly.

One side of me thinks in order to be the most efficient you can be you need the fastest machine you can afford, I mean there is nothing worse than waiting for an application or a process to open when you are in the flow of something. This is something that is at least in part backed up by the likes of Joel Spolsky when he wrote the Joel Test (see point #9).

The other side of me thinks that the bottlenecks to productivity are only superficially to be found on your machine, I mean people *did* get stuff done before the MacBook Pro came out, so what is my excuse? This point is something similar to what was mentioned in a recent Back to Work podcast episode where Merlin Mann said that if you are a writer then in theory you should be able to at least do part of your work with a pen and a bit of paper.

I can see the benefits of both, and I suppose that probably want you want is the mindset of the latter with the equipment of the former, but in saying that there are some drawbacks to following either road.

If you are happy using your 5 year old netbook to code on that is running 2GB of RAM and is rocking a sweet 60GB SATA drive then you are probably well versed in its quirks and you have saved a load of money compared to someone who upgrades their laptop every year, this is a good thing, but if you splashed out on a better machine 3 years ago that shaved 3 minutes off your day, every day for those three years it would save you over 50 potentially billable hours, that is a lot of money you could be leaving on the table.

Conversely, if you are always throwing RAM at the problem and have been playing with SSDs since they were released then you haven’t wasted those 3 minutes a day waiting on something chugging itself along, but you have maybe failed to appreciated what you have and maybe you haven’t thought about smarter ways of working because you haven’t had that 9 second wait while something reloads.

One part of me wants to resolve this by saying, even the fact that I am aware of the advantages afforded to me with the latest kit means I have an appreciation for what it would be like to use sub-optimal gear, but I think there is a massive difference between hypothesising about something like this and actually living and working with old stuff.

Then of course there is the cloud, why would we need good hardware when we do everything on the cloud these days!

Thanks to Ryan McDonough for creating this image when I couldn't find the original. Find him on http://twitter.com/ryanmcdonough

Thanks to Ryan McDonough for creating this image when I couldn’t find the original. Find him on http://twitter.com/ryanmcdonough

Funny picture aside, it is true, there are many things we used to think we needed to process on our hardware that we now do on someone else’s over the internet, I think so far the pinnacle of this is something like the Chomebook which doesn’t allow you to easily code directly on it, but with a plethora of web services that allow you to code with them it isn’t really an issue.

The next question then is do web developers need high bandwidth? For me there is nothing to think about, bigger is better and I think the faster your internet speed the more productive you can be in this day and age.

We download and upload large files more than we probably realise, and with the amount of events and tutorials that are either live streaming or high quality downloads/playback the bigger your pipe the quicker you can get access to this content. The only potential upside to having a slow internet connection is that it would really give you an appreciation that your site needs to be performant when being forced through narrow pipes, but we have plenty of tools that allow us to check if that is the case without actually limiting ourselves.

Side note; If you do want to throttle your bandwidth for any reason, I made a quick script that will work on *nix machines and Mac OS X.

One best of both worlds example would be to have the best gear money can buy but be ultra strict about spotting failings in your current workflow, basically finding anytime you have to type something over and over again, or anytime you need to complete a series of events, make sure you log them and attempt to eliminate them.

An example this of occurred to me just this morning, I use the terminal a lot in web development and I am working on one main project right now which is located in my Sites directory. So every morning I would turn on my machine, open the terminal and type cd ~/Sites/ExamTime, it is only a couple of key strokes to do this, but I have better things to be doing that moving into a directory every morning (or every time I close a terminal window by mistake) a quick visit to the settings panel and I have made my terminal do those key strokes for me, I will never need to worry about that again.

To wrap up my admittedly rather loose thinking on the subject I suppose I should share my setup, before I do, I would love to hear your thoughts on the subject, Twitter, Reddit, Hacker News.

I hack on an early 2011 MacBook Pro with 16GB of RAM and an i5 Processor, I have a 255GB SSD in it and it is running Mountain Lion.

I write on a 2012 Samsung Chromebook, it has 2GB of RAM and a 16GB SSD, it is on the dev channel of ChromeOS.

I have no plans to upgrade either of these machines.

Share this on

Stack Exchange is winning the internet and this is not a good thing

I have blogged about how much I like the Stack Exchange sites in the past and my opinions on their usefulness haven’t changed one bit, but I am noticing a trend that I wanted to discuss briefly.

Lets say I am new to a programming language and I want to know how to concatenate two strings, time was that the canonical result from a Google search would probably be a link to some spec documents or some general advice around the language. This isn’t the case anymore, now you often get a Stack Overflow answer as your first result.

I just tried this by searching the following term: “concatenate strings in go”

Concatenate Strings in Go

Concatenate Strings in Go

The first three results from my search (I say my search because Google weights each search individually to the user making the search) all point to Stack Overflow, interestingly the second result is actually pointing to a Ruby answer, which is weird but it highlights the strength of Stack Overflow answers on the Google search index. This is why I have said they are winning the internet.

Why I don’t think this is a good thing is because whilst for someone who is already happy with the language and has a very specific question this is excellent, but in the case of needing to concatenate two strings we can infer that the user probably doesn’t have much of a background in the language and I don’t think this straight to the point question and answer setup is the best for this person.

The question they find will more often than not talk about an edge case where the first answer might be best suited to that edge case but perhaps not best suited as a general rule of thumb, and indeed other answers that are perfectly valid in a general case may be voted down in this specific case and a rookie user will probably not pick up on that.

The fact that Stack Exchange answers appear so high in search results often means as well that people assume that if it isn’t on the Stack Exchange they should ask it, which leads to too many questions being asked that could be answered by reading the manual or doing a tiny bit of experimentation.

This extremely efficient mechanism for finding out the exact answer to your question is creating a generation of very efficient, but perhaps not entirely well rounded developers who can churn out code very quickly but perhaps don’t understand the code as well as they should.

I should point out, this is in no way the fault of Stack Overflow, they are providing an excellent service and they are clearly doing their fair share of Search Engine Optimising to be able to achieve such results, I think that if any physical thing is at fault here it is maybe Google, they are charged with finding people the most relevant result and whilst on paper an exact match between your query and a Stack Overflow question should result in Stack Overflow being the canonical link, I am not sure it is the most relevant link in practice.

To be honest to call Google at fault is probably clutching at straws, the real issue I think is that too many developers are happy to dive in and ask someone to do their thinking for them before properly trying to solve the issue themselves, I don’t know how we fix that.

By the way, here is the best way to concatenate strings in Go, via Stack Overflow of course :-)

package main
import "bytes"
func main() {
    var buffer bytes.Buffer
    for i := 0; i < 1000; i++ {
        buffer.WriteString("a")
    }
    println(buffer.String())
}

If you want to discuss this you can hit me up on Twitter, or there are Reddit and Hacker News threads.

I spoke to Jeff Atwood on Twitter about it and this was his response:

Joel Spolsky also got back to me about it:

Share this on

Using Bootstrap’s typeahead from inside a modal window

If you want to use bootstrap’s typeahead functionality from inside a modal window such as lightbox or facebox then you are probably going to have to make a small edit to one of the bootstrap files.

Open up bootstrap-typeahead.js in your text editor of choice and then add a z-index of 9999, like so;

  this.$menu.css({
    top: pos.top + pos.height,
    left: pos.left,
    'z-index': 9999
  })

You probably don’t need to go as high as 9999 but it worked for me!

It took me way too long to get this working, other bootstrap things appear to work fine inside modals.

Share this on