Coding on a plane… on an iPad

The project

In my ongoing efforts to up my development game, I’m currently working on learning how to create an app that has user authentication. Adding authentication to the web app is completely new to me and as always I’m time constrained. So when I found myself in a plane on the runway for over an hour thanks to a mechanical issue I thought why not try and get some study done on my iPad.

I had previously downloaded all my courses content on the Udemy iPad app. This was some luck on my part as streaming video content over a 4G data connection would quickly blow through my data cap which wouldn’t be ideal. I also had a bunch of dev apps I’d downloaded ages ago but hardly ever used.

The setup

I wasn’t sure how much I would really be able to do given I had a set of tools that I guess you’d call “non-traditional” from a web development perspective. Here’s what I used:

  • iPad Pro 10.5 – This continues to be a great machine for me. The screen size gives me a lot of flexibility without the bulk of the 12.7. It does have its limitations of course but increasingly iPad is filling more and more of my needs
  • iPhone 6s – My iPad doesn’t have LTE so I used my phone as a hotspot to connect to the internet
  • Textastic – While of course I wish had a text editor with all of the power of a desktop app, Textastic is the best I’ve found so far on iOS. The code highlighting is nice, it comes with a range of themes and custom fonts and works seamlessly with my iOS GitHub client of choice, Working Copy
  • Working Copy – This is one of those apps that constantly amazes me. It feels like this is an application that just shouldn’t be able to work on iOS but somehow it does. I had absolutely no issues connecting to my GitHub repos, downloading the latest build of the project I was working on, making changes in Textastic, then pushing those changes back to GitHub. Perfect!
  • Udemy – The work I was doing was part of the Udemy course I’ve been working through and thankfully the app supports downloading the course content to the device.

What works well

The fact this was possible at all feels sort of amazing. For the most part, the applications I used (listed above) did a great job at the basics and in some cases were far more. I think the thing that really stood out to me most was how the single view full-screen apps made me less likely to switch between apps and, as a result, help me focus on what I was doing more. That focus altered my workflow quite a bit. I’m not sure it was better or worse, but it was certainly different. Thinking about it I think I was far more likely to stay in my text editor and write code from my own mind rather than relying on the content of another window.

I also think the lack of some of the power features of a desktop text editor meant I was paying more attention to everything I typed. Not having the code editor automatically format my text for example really made me pay attention to how I was laying out my code because I knew it wouldn’t be reformatted on save. It will be interesting to see the differences between my handwritten code and what my normal beautified code looks like.

What could be better

Screen real-estate – Whenever you’re doing web development you need a few windows open at a time. You really can’t have too much screen real estate in this sort of work so a 10.5-inch screen is always going to be tight. Having said that it wasn’t horrible either.

Testing – The iPad doesn’t have a terminal nor can it run a node or mongo server so I wasn’t able to test my code. While it’s not a big deal given I was just following a tutorial I wouldn’t want to spend to much time working on something without being able to see the results of my efforts. That would run the risk of building issues on top of issues and it might lead to a lot of wasted effort. I could have used Panics excellent Prompt but the app I’m working on isn’t running on anything other than my local dev environment on my Mac. Sorting that from my iPad was more effort than I was prepared to make, although it probably could be done.

Textastic – I like the look and feel of Textastic but compared to my normal desktop setup it feels a li bit like coding in the dark. These may be features I’m oblivious to but I couldn’t see any form on code completion, code beautifying, or much beyond code highlighting. Not a deal breaker of course but it’s another little thing that makes you less productive.

Udemy app doesn’t support split screen – This really means a lot of switching back and forth between apps. Picture in the picture did work but because of the screen size, it made the screencast unreadable so that was of limited value.

I’m really interested to see how iOS continues to evolve as a part of my development workflow. With Apple splitting iPad off into its own OS (iPadOS) it’s difficult to imagine a future in which the iPad doesn’t become an even more capable development machine. With the increasing levels of support for external displays, full-blown safari support and other extended capabilities it’s not impossible future iPads might become fully capable dev environment. At least in some use cases.

The thing I’d like the most that would make the biggest difference is a terminal app. It’s a bit of a pipe dream as I can’t see Apple going that way, but I can dream, right?

How much time should I spend a day learning to code?

This is the question I asked myself when I first started learning (well relearning really) to code a while back. Obviously I Googled this and found some really interesting answers, but generally speaking, the common wisdom is about 4 hours a day.

I call bullshit on this. In my experience (and your mileage may vary) you should code every day, but it really doesn’t matter how much. Sure, you’ll get to the destination faster if you’re able to put 4 hours a day, but that number is completely unrealistic for a good chunk of the population.

Personally, I have a full-time job, 2 young kids, and a wife. 4 hours a day is an absurd amount of free time for me each day to work on much of anything. So when I study something I work to a very simple philosophy. Do some study every day. That’s it. Change is all about momentum. You don’t have to stop sleeping to make a change, you just have to show up every day and do something.

Routine is key

My personal routine is to get out of bed early, normally around 5-5:30am. Then I do as much of my course work before the kids get up as possible. Normally I’d get around an hour or so done. Some days I might sleep in and only get 30 mins, but I still progress. To solidify my learning, in the evening I go over what I did in the morning and write up notes. Sometimes those notes turn into a blog post. In that way, I’m sort of doing double duty. Sharing what I’ve learnt and documented it for my own retention all in one.

The thing about learning anything over and above your already busy life is that you have to make it accessible or it won’t work. Lowering the barrier to just do something each day means I might only research something I learnt the day before or add some comments to code I wrote a week ago. It really doesn’t matter what it is, as long as I get started each day.

So if you’re wanting to study but don’t think you have the time? Explore study options that let you learn in small chunks and to your own deadlines. I’ve found both Udacity and Udemy great services for this sort of thing. You won’t get a formal qualification from these services, but if you’re just interested in the skills then does that really matter?

Github Learning Lab🔬

I’ve been using GitHub for a while now as part of my spelunking into the world of VR and Mobile development. I think it’s fair to say it’s done a great job of protecting me from the inevitable mistakes of learning something new. Having said that, it does take a while to get your head around anything other than the basics.

Thankfully there are a large number of resources available to help you along the way. Most recently I discovered GitHub Learning Lab, a fantastic resource for learning how to use the platform for your own projects or contributing to others.

I think the thing I enjoy most about this particular option for learning is that it’s actually using the tools themselves. Yes, there is text and video to consume, but you actually use GitHub itself to work with the course material. I’m a real learn by doing sort of person so this sits particularly well with me.

So if you’re new to GitHub, or just want to solidify your knowledge of it, I suggest you take a look.

 

How to: Setup CocoaPods in Xcode

Hey, guess what? I’m learning iOS development and have been for months! Thought I might increase my rate of publishing to my blog if I did what I did for my VR course and posted study related stuff here. So to that end…

Here’s a simple step by step guide for adding CocoaPods to your iOS projects. There are quite a few steps involved and I suspect this is something that is done relatively infrequently in a single project. It’s always nice to have a reference for this sort of thing.

Steps

  1. Inside Terminal, change directory to the folder containing the Xcode project
  2. Initialise a new Podfile. You do this by using the “pod init” command. If you need more details read about it in the CocoaPod’s guide for pod init
  3. Open the Podfile in Xcode. Just drag it to the Xcode icon in the dock
  4. Add the library to the pod file. Here’s an example Podfile with SwiftyJSON and Alamofire libraries added
  5. Install the pods using the “pod install” command in Terminal. Here are more details on pod install should you need them
  6. Now open your Xcode project via the new .xcworkspace file

Easy as pie.

Udacity VR Nano degree retrospective ⏳

When I started my Udacity VR Nano degree I knew I was in for a challenge. Now that I’ve successfully completed my final assignment I thought I’d share some lessons learnt. So in no particular order:

  • Use version control. Thankfully I started doing this very early on. I had heard of the benefits and for whatever reason actually took them seriously. I started a religious habit of regularly pushing changes to GIT. I only used GIT to roll back to previous versions of projects hand handful of times, but had I not had the option I would have had a much bigger problem on my hands.
  • Don’t underestimate the time required. Taking on any study that requires large blocks of time can’t be taken lightly. It’s not going to be enough to only do a 30 min stretch at lunch, or an hour once the kids are in bed. You’re going to need a clear half day at least once a week to make real progress. Also, make sure you know what’s going to consume your time on projects in any given block. No sense clearing 4 hours for study only to have 3 hours of that time consumed rendering a 4k 360 video.
  • Don’t forget to look after yourself. With pressure on your time, it’s easy to cut out things like exercise or time with your family. Don’t do that. Cut out things that are actually a waste of time instead. TV is a big one but also think of ways of compressing your time. Like listening to audio books while you go for a run rather than reading a book alone.
  • Take breaks. If your mind is cluttered you’re not going to learn as well as you might. I found when I spent more than an hour trying to solve an issue the thing to do was take a 20-minute walk, clear my head, then take another crack at it. It’s amazing how often your mind will solve problems for you when you let it.
  • Take notes. Even if you never refer to them, take them anyway. Do this with a pen and paper (or a tablet and a pencil). It’s all about making the information get in your head. I almost never refer to my notes, I don’t take them to remember later. I take them to remember them now.
  • Try and integrate your life into your study. I did this by using my kids as the target audience for my projects and used them as user testing subjects while developing. It let me spend quality time with them and get some study done. It was also an education for them too so a real win-win.
  • Scope out what you’ll need before you begin. I started my course with a late 2009 Mac Mini. While old, it was fine for much of the course. The later parts that required 4k 360 video editing, not so much. This sort of thing can add considerable costs to your study budget so make sure you have a line of sight on this and save accordingly.
  • Get involved in the community. A huge part of successful study for me was the community of learners and educators around the subject. Help others and ask for help when you need it. Don’t waste time beating yourself to death if you get stuck. Solving your problem on a public forum helps everyone else with the same issue in future. So don’t be selfish, ask for help.
  • Be grateful. To your partner for looking after the kids. To your friends for listening to your ramblings about project issues. To your classmates and mentors for helping you along the way. Be grateful.
  • Stick it out. Software development is hard. It’s not supposed to be easy. It is literally constant problem-solving. There will be times you’ll think “maybe I’m just not good at this”. Just keep going.

Done: Night at the museum ☑️

I’ve been AFK for a while (holiday) so I just wanted to post the details of the final version of “night at the museum” I finished a few weeks ago that I delivered as part of my Udacity VR course.

The project went well (in that I passed) but I have to admit it was an exercise in restraint as much as anything. Like a lot of people, I tend to have big plans for everything I make but those plans are not always practical. This project was no exception. While I am ultimately happy with what I created, I do consider it very much a minimum viable project. When it comes to working on assignments like this there are a number of things to consider. First and foremost for me is available time.

I’m totally loving learning VR development, at this point, I spend almost all my free time doing it. But working full time and having a young family is a busy time in life, so if I want to progress projects I have to be efficient with my time or things can stagnate. Also, I currently pay for my studies via a monthly subscription so every extra month a project slips into comes at a significant extra cost.

Just to give you a few examples of compromises made on this project:

  1. Playing content at each of the stations was fairly limited and doesn’t have much finesse. For example, the final build allows the user to play audio from all 5 stations at the same time, this leads to a fairly horrible experience if a user does this
  2. I reused a museum model from a previous project because it was faster than building my own. This means it’s not really an ideal setup. Space feels a little constrained and doesn’t provide much room to move about. Most real museums are quite spacious so it didn’t really fit the aesthetic I was aiming for
  3. I wasn’t that happy with the spatial audio implementation. The environment had a bit too much reverberated for my liking and given more time I would have improved this a bit
  4. There’s no environmental audio, just the content of the stations. I’d preferred to add some atmosphere to the scene just to add the feel of the place

There are loads of other things that could be better about the final deliverable, but ultimately what was made “did the job”. Creating anything is always a series of compromises and I think delivering something you can live with and (resourcing permitting) can be built upon, is more important than getting things perfect. Perfection, after all, is the enemy of the shipped.

If you’re interested in the project’s code, it’s all available on my Github account. Enjoy.

Storytelling​ in VR 📖

It’s hard to not have “all the feels” watching the above video (Ideally in VR if you’ve got a cardboard headset). The creators have done such an amazing job of crafting a great story with some seriously well thought out VR technique.

For example transitions/cuts within a 360 video like this can be very jarring, and require the user to reorientate themselves with each cut. In this video, they’ve used the fixed position of the car interior to ground the viewer. It’s extremely effective at controlling the flow of the experience.

The audio is also exceptional. Not only does the song do a great job of creating an emotional connection to the characters, but the changes in audio based on when the characters are inside or outside the car are just wonderful. Spatial audio at its finest.

Just a beautiful bit of work.

Optimising C# scripts in Unity 🏎

C# logoThe more I create C# scripts in Unity the more I learn about optimising those scripts. With code there are 100s of ways to solve a problem, not all of them efficient, so learning to check your codes performance seems like a must.

Things to look for

So far I’ve come across a few simple things to look out for on the projects I’ve been coding. I’ll post more as I come across them in future.

  • Anything that’s called every frame creates consistent load on the CPU, GPU or both. If what’s called is inefficient or large it will have a negative effect on frame rate. In VR this is particular bad given low frame rates can make your user physically sick. Be sure to look at what’s in the Update and FixedUpdate methods and do your best to optimise the code as much as possible.
  • Working on mobile we will almost always be maxing out the graphics capability of the device. This effects the performance of the Update method. On the other hand FixedUpdated runs in sync with Unity’s physics engine. This will make sure your physics will be the most accurate and consistent. FixedUpdate is called every “physics step”, so is regularly used for adjusting physics (rigid body) objects. Make sure you always put your physics code in FixedUpdate.
  • Avoid using GameObject.Find. It basically requires the system to cycle through all of the GameObjects in the game to find the right one, which obviously is expensive for the CPU. If you know what object we are using ahead of time, define the object at the top of the script and reference it that way. GameObject.Find is useful for testing out ideas, but that’s about it.