Apps, Research, Technology

Apps in Research

On Monday I gave a presentation at the BASES Heads of Department Forum at Staffordshire University on using apps in research. You can download the presentation here. My take-home messages from the presentation were that (1) we need to do more studies on the validation of apps, particularly if they are going to be used for exercise prescription and in clinical use; (2) there are very exciting developments for using apps to recruit participants and collect data for research projects, such as Apple’s ResearchKit and IBM’s Watson Health Cloud, and (3) it’s not easy or cheap to develop apps for use in research projects. I firmly believe that there is considerable scope for both academic and community impact through the use of smartphone apps and other wearable computers. For example, it is estimated that by next year more than 2 billion people around the world will own a smartphone. Although I will continue to conduct research in sport, my growing research focus over the coming years will be the use of technology in physical activity and health. If you’re interested in this type of research then do get in touch.

Standard
Programming, Technology

Swift

At Apple’s 2014 World Wide Developers Conference (WWDC) a new programming language called Swift was introduced. Big deal you say? Well, for most Apple developers (both full-time and part-time – (like me)) it was a shock. There had been no rumours, which for an Apple release was unusual. We thought Objective-C would live forever! But the king was dead – long live the king. For me, Objective-C had played a large part in helping me to learn to programme. It’s quite ‘English-like’ in it’s syntax, which means you can generally tell what a piece of code is doing. For example:

NSString *myText = @"Hello World";

It’s fairly clear what this line of code is doing – you are assigning the words ‘Hello World’ to a variable called ‘myText’ (forget about the NSString[1] thing for now). Easy hey? Now here’s how to do it in Swift:

var myText = "Hello World"

Even easier! There’s no need to reference the class of object (NSString) because Swift knows that ‘Hello World’ is a string of characters (hence the class name). This is called type inference, and it’s a big thing. You can do this with other data types as well like numbers. Assigning a number to a variable in Objective-C and then Swift involves:

int myNumber = 5;   //Objective-C
var myNumber = 5   //Swift

Again, Swift knows that 5 is a whole number and it’s therefore an integer (int), so there’s no need for you as the programmer to inform the computer about this. To assign a floating point number involves:

float myNumber = 5.2;   //Objective-C
var myNumber = 5.2   //Swift

Swift also makes it really easy to combine strings together, like:

var string1 = "Jim"   
var string2 = " You're great!"   
var combinedString = string1 + string2

It’s a little more complicated in Objective-C:

NSString *string1 = @"Jim";
NSString *string2 = @" You're great!";
NSString *combinedString = [string1 stringByAppendingString:string2];

Incorporating data into text is easy in Swift too:

let num1 = 6
let num2 = 4

if num1 > num2 {
    println("\(num1) is greater than \(num2)")
} else {
    println("\(num1) is not greater than \(num2)")
}

The equivalent in Objective-C:

int num1 = 6;
int num2 = 4;
      
if (num1 > num2) {
     NSLog(@"%i is greater than %i", num1, num2);
} else {
     NSLog(@"%i is not greater than %i", num1, num2);
}

Not a lot of difference there, but I think the Swift version is a little easier to read.

Now, arrays. An array is a collection of objects. For example, a collection of numbers. In Objective-C it’s this:

NSMutableArray *myArray = [[NSMutableArray alloc] init];
[myArray addObject:[NSNumber numberWithInt: 2]];
[myArray addObject:[NSNumber numberWithInt: 4]];
[myArray addObject:[NSNumber numberWithInt: 6]];
[myArray addObject:[NSNumber numberWithInt: 8]];

In Swift it’s just this:

var myArray = [2, 4, 6, 8]

Yep, that’s all there is to it! One of the problems with learning to programme is that people think it’s too hard. They say “I’m not smart enough to do this”. Well, if I can learn it then anyone can! That being said, there are quite a few ‘gotchas’ with Objective-C, and aspects of the language that are difficult to grasp. I think Swift is easier to comprehend than Objective-C and therefore easier to learn, so I’m confident that Swift will enable more people[2] to pick up programming for iOS and the Mac, and that’s a good thing.

GA.


  1. This is what’s called a ‘class’. A class is essentially a template for making things. In this case it’s a template for making ‘string’ objects, which in everyday language are words. I’m guessing the word string comes from a ‘string of characters’, which is what a word is. When you want to make a new string, you ask the class to give you one. You can then do things with that string, like assign it to a label that appears on screen. The ‘NS’ is a reference to NeXTSTEP, which was an operating system created by NeXT Computer, a company that Steve Jobs started after he was kicked out of Apple in the mid 1980’s. NeXT Computer, and the NeXTSTEP operating system were bought by Apple in 1997 when Jobs returned to Apple and were eventually turned into OSX and iOS.  ↩
  2. On that note, I’d encourage any university student to have a crack at learning a language. A number of my PhD students have started doing so and it has allowed them to analyse data in new ways that they couldn’t do with off-the-shelf apps.  ↩
Standard
Academia, Technology

Hello world

Welcome to my new blog. Here I’ll be writing about academia, sport science, technology, programming, and anything else really that I’m interested in. I’ve just taken delivery of a new Macbook Pro, so thought it would be an ideal opportunity to start writing. I bought a nice little app from the Mac AppStore called Byword, which uses a plain-text based language called Markdown. Markdown makes it easy to focus on the content rather than formatting. The blog is being hosted on WordPress, and together with the Byword app on Mac and iPhone, it means I can write wherever, whenever I like. There are clear advantages to writing within a minimal environment rather than bloated apps like Word, and already I’m enjoying the experience. Check it out for yourself. I’m also keen to explore how Markdown and Byword could be used to write an academic paper, and based on others experience, citations and footnotes might need some experimentation.

Along with my other social media endeavors, I’m very keen to write more long-form pieces about my experiences within academia. There’s a lot to get off my chest. Hearing about my journey might also be useful to those who follow.

GA.

Standard