It's Sean!

UK freelance journalist, author
and writer Sean McManus

Printed from www.sean.co.uk. © Sean McManus.
You are here: Home > Blog Home > Sean McManus's Writing blog: July 2014

Sean's Tech and Writing Blog

Download ScratchJr for free on the iPad

30 July 2014


The team behind the Scratch programming language has released ScratchJr for the iPad, following a successful Kickstarter campaign which I was pleased to support with a small donation. ScratchJr is aimed at younger children, aged 5 to 7 years old, and has a simplified interface and set of blocks for making scripts. It has some great looking graphics, and the blocks can be used to create some surprisingly sophisticated effects. The app can be used to make stories with different scenes (a new feature in ScratchJr), and simple games too.

Our nieces and nephews are already experienced iPad users, so I'm confident that the interface will present no challenge at all to young children. They quickly learn what the icons mean and happily explore what they do.

Here are three scripts you can use to make an arcade game in ScratchJr:

Screenshot of ScratchJr program - see explanation below

The Alien Shooter game

To understand how that program works, and get an overview of the new app, see my review of ScratchJr on the iPad, including how to make an arcade game. If you're a fan of ScratchJr's older cousin Scratch, check out the bonus resources from my book Scratch Programming in Easy Steps.

Bookmark and Share
Permanent link for this post.

0 comments

Top 10 Tips: How to design applications for Google Glass

28 July 2014


At this month's Londroid Meetup at Skills Matter, there was a chance for developers to learn more about how to create successful apps for Google Glass. It presented an opportunity to see the devices, but most importantly, a chance to hear from Google representatives about what Google has learned about making Glass apps through trial and error. Senior developer advocates Hoi Lam and Timothy Jordan gave talks, sharing their favourite apps and best practice using Google Glass.

(You can read my article about the UK launch of Google Glass in London, including a review of how it works, here).

A close-up of a Google Glass in use

A Google Glass device in use. More photos here.

Here are the key takeaways I noted:
  1. Know your techs. There are three ways you can develop Glass apps. You will be able to use the upcoming Android Wear notifications, which will push notifications from your Android phone to your Google Glass. You can use the Google Mirror API if you have a web service to deliver that into Google Glass with minimal changes. Or you can use the Google GDK (Glass Development Kit), which adds some Glass-specific features to Android, including voice triggers and gestures. The Mirror API can enable you to implement your app more quickly, but it means output is pulled from the cloud. It's best used when it will feel intuitive to the user if there is a delay in getting information, such as in a searching application. The GDK is suitable when you need an app to work offline, need a real-time response, or need deeper hardware integration.
  2. Design around user intent. Although I'm talking about applications here, Glassware, as they call it, isn't like a phone or a tablet app. Users won't expect to open an app and then do something. Instead, you should design around their intent and cut the time from their expression of that to you delivering a result. For example, a tablet user might open a mapping app and then search for directions. A Google Glass user would just ask for directions.
  3. Design for Glass. App developers are experienced at porting from "one rectangle to another", but Google Glass isn't just a smaller rectangle. It's so different to existing mobile platforms, that you need to rethink the experience you provide. Jordan suggested thinking about what it is you always wanted to do with your services that you can now do with Google Glass, and then focus on that one feature. Wordlens, for example, provides hands-free translation of signs using the camera, leaving your hands free for maps and baggage. Augmedix enables doctors to look up medical information without turning away from the patient, and enables them to build stronger rapport and better study the patient's condition.
  4. Don't get in the way. Google's vision for Glass is that it should not interrupt the user and take them out of the moment. Lam had a great example of how he's been using Google Glass to photograph his daughter while playing with her. He can look at her all the time and use both hands to guide her on the climbing frame, but can capture that moment using Google Glass. Google's aim is that the device should enhance living in the moment, rather than pulling people out of it. As a result, users should be able to ignore your Glassware without any penalty, and it shouldn't require them to take action.
  5. Be relevant. Google Glass isn't designed to provide all the information, all the time, just what's most relevant now. Think about how you can use contexts like the time of day and the location to provide relevant information to the user when they need it. For example, it would be great if a shopping list app presented a reminder just as you're passing the shop, Jordan suggested. Because of the need to focus on what's relevant now, you can't just port your mobile apps across and expect to end up with something usable.
  6. Avoid the unexpected. One of Google's guidelines is that you shouldn't surprise the user in a way they don't want. This probably applies to every platform, but it's especially important for Glass, because the nature of the device means that unpleasant surprises would feel particularly intrusive. Nobody wants to see cabbage adverts in their glasses at 3.30am. Jordan presented CNN as a good example of managing expectations. When the software is configured, it makes it clear to the user how many alerts they will see and when they're likely to see them.
  7. Build for users. Jordan said that Google had tried building some applications that didn't work, and advised against building something just because it seems cool and takes advantage of the technology. Instead, you should focus on a problem that people have and help them to solve it. Again, this might seem like something that applies to every platform, but it's still a good filter to put your idea through before developing it. The idea of a facial recognition app came up that would tell you who somebody was when you met them again, having forgotten their name from your previous encounter. That seems like a cool idea, but it would get in the way of the real social interaction. In practice, I think it would be pretty hard to use without somebody knowing it was being used on them, which would be a particularly graceless way to socialise. (Facial recognition apps are currently not allowed on Google Glass in any case).
  8. Be wary of head gestures. They can be a cool way to control Google Glass, but people lack fine motor movements, so they're not good where precision is required, including in scrolling.
  9. Make it glanceable. Jordan presented two different designs of a running app, both of which showed the steps taken and the percentage of the run completed. One of the pics had a photographic backdrop showing some running shoes. When the room was polled on which design they preferred, it was evenly split. The screen with the shoes in, though, took longer to glance at, eye-tracking studies had shown. The eye is distracted by irrelevant information and graphics, and when you're running, you can't take in information as quickly. Keep the design simple, and think about what the user really needs. During the run, they need coaching support, not a complete data set.
  10. Expect design delay. Plan to spend time iterating on the user experience. Until you've tried it, you won't know what works effectively, so allocate plenty of time to experiment with this new interface.

It's early days for Google Glass, and there was a lot of excitement in the room just seeing the devices and trying them out. There's clearly a lot of potential for innovative new applications, particularly for platform-based services, which will be better able to build a business model on a device that is not conducive to advertising, and that does not yet support monetisation. What are your thoughts on Google Glass?

Bookmark and Share
Permanent link for this post.

0 comments

Avoiding the race condition bug in Scratch

03 July 2014


When I discovered Scratch, I was fascinated to see that the language enables you to put scripts on different sprites, or multiple scripts on the same sprite, that appear to execute at the same time. This is a bit like threading, an advanced programming technique that enables you (in very basic terms) to have different bits of a program executing in parallel (at the same time).

There is a special class of bug that emerges when you're dealing with parallel code, which is the race condition. This happens when two different bits of the program "race" to do something at the same time, and the programmer doesn't have control over which "wins".

For example, if I put all these scripts on the same sprite, what is the final value of the score variable?

four scripts that start on the green flag and all change the variable score to something different

It doesn't matter what your guess is, because there's no sure way of knowing how it will behave next time. It might change depending on what else is going on in the program, or a minor update to Scratch might change the synchronisation too. Logically, it's not something you can control. If you ask the program to do four things at the same time that don't make sense together, you risk getting unexpected results.

From my own quick and dirty experiments, it looks like the one that runs last (and ultimately sets the score) is the one you edit or move last. So if you, in the editor, drag the set score to 0 block and then click the green flag, the final value of score is 0. To get the value 8, drag the blocks in this order: set score to 0, set score to 5, change score by 2, change score by 1, and then click the green flag. I put all these scripts on the same sprite. When you have more than one sprite with conflicting scripts on it like this, sprites that were added to the program first have higher priority over the final result. So the cat seems to trump other sprites, for example. I ran my test in Scratch 2.0, but the results are different in Scratch 1.4, and might even be different for you running Scratch 2.0. And they might be different tomorrow for either of us. There's no reason why they have to stay the same.

That's a bit of a diversion because this information isn't really useful to you: for the program to make sense to others (an important part of programming), and to always run reliably (even if someone else moves a script), you need to avoid race conditions like this, not work around them.

It might seem like this is a bit of an artificial example (okay, it is), but similar problems can often occur when lots of scripts start when the green flag is clicked, or the background changes, or when there is a particular broadcast. There have been a couple of times I've experienced problems similar to this, including when writing Hangman for my book Scratch Programming in Easy Steps and the Shaun the Sheep Football game more recently.

There are a few strategies you can use to avoid race conditions:

  1. Avoid having more 'green flag' or other hat scripts (with rounded tops) than you need. If you can combine them without causing any problems, it's best to do that. That enables you to determine the order the blocks run in.
  2. If you have a bug that might be caused by a race condition, try adding wait blocks to delay some of your scripts so they execute in an order you can influence. This is a real fudge so I wouldn't recommend it for final programs, but it can be valuable for finding bugs when you're testing your program.
  3. Use Scratch broadcasts to synchronise between sprites where necessary. For example, you could have a green flag script that sets up your variables and gets everything else ready, and then sends a broadcast to start scripts on other sprites. That avoids a clash where the other sprites might be trying to use variables you haven't set up yet (for example).
  4. Use the broadcast and wait block where it makes sense. That stops your script steaming ahead before getting the results it needs from other scripts that it's triggering.

Have you experienced bugs like this? How did you overcome them? Let me know in the comments below.

For more on Scratch, take a look at my books Cool Scratch Projects in Easy Steps and Scratch Programming in Easy Steps.

Bookmark and Share
Permanent link for this post.

4 comments

Dip into the blog archive

June 2005 | July 2005 | August 2005 | September 2005 | October 2005 | November 2005 | December 2005 | January 2006 | February 2006 | March 2006 | April 2006 | May 2006 | June 2006 | July 2006 | August 2006 | September 2006 | October 2006 | November 2006 | December 2006 | January 2007 | February 2007 | March 2007 | April 2007 | May 2007 | June 2007 | July 2007 | August 2007 | September 2007 | October 2007 | November 2007 | December 2007 | January 2008 | February 2008 | March 2008 | April 2008 | May 2008 | June 2008 | July 2008 | August 2008 | September 2008 | October 2008 | November 2008 | December 2008 | January 2009 | February 2009 | March 2009 | April 2009 | May 2009 | June 2009 | July 2009 | August 2009 | September 2009 | October 2009 | November 2009 | December 2009 | January 2010 | February 2010 | March 2010 | April 2010 | May 2010 | June 2010 | August 2010 | September 2010 | October 2010 | November 2010 | December 2010 | March 2011 | April 2011 | May 2011 | June 2011 | July 2011 | August 2011 | September 2011 | October 2011 | November 2011 | December 2011 | January 2012 | February 2012 | March 2012 | June 2012 | July 2012 | August 2012 | September 2012 | October 2012 | December 2012 | January 2013 | February 2013 | March 2013 | April 2013 | June 2013 | July 2013 | August 2013 | September 2013 | October 2013 | November 2013 | December 2013 | January 2014 | February 2014 | March 2014 | April 2014 | May 2014 | June 2014 | July 2014 | August 2014 | September 2014 | October 2014 | November 2014 | December 2014 | January 2015 | February 2015 | March 2015 | April 2015 | May 2015 | June 2015 | September 2015 | October 2015 | December 2015 | January 2016 | February 2016 | March 2016 | May 2016 | July 2016 | August 2016 | September 2016 | October 2016 | November 2016 | December 2016 | January 2017 | April 2017 | July 2017 | August 2017 | Top of this page | RSS

Books by Sean McManus

Scratch Programming in Easy 

Steps

Scratch Programming in Easy Steps

Raspberry Pi For Dummies

Raspberry Pi For Dummies

Learn to program with the Scratch programming language, widely used in schools and colleges.

Set up your Pi, master Linux, learn Scratch and Python, and create your own electronics projects.

Super Skills: How to 

Code

Super Skills: How to Code

Web Design in Easy Steps

Web Design in Easy Steps

Learn how to code with this great new book, which guides you through 10 easy lessons to build up your coding skills.

Learn the layout, design and navigation techniques that make a great website. Then build your own using HTML, CSS, and JavaScript.

More books

©Sean McManus. www.sean.co.uk.