Thursday, 30 September 2010
A UITableView with an "empty" view
Wednesday, 29 September 2010
Building a Boost framework for iOS (iPhone, iPad, etc)
The good news: Boost 1.44.0 builds for iPhone a lot more easily than previous versions.
But first, why?
First, let's answer the obvious question: Why would you want to bother building a framework at all?
Quite simply: to make your life easier.
Using the native Boost build, you (may) need to link against a number of different Boost libraries in your application. And then you need to do a clever dance to ensure you link against either the i386 (simulator) or armv6/armv7 (iPhone devices) versions, depending on your build configuration.
That is tedious and annoying, and not the way it should be. Other Apple "libraries" are provided as a "framework" which you just need to mention once in Xcode, and then the build system works out how to link to the correct version and how to find the right headers.
So, if we can turn Boost into a framework life would be so much easier.
And that's what I have done.
Executive summary
Now, you can do it too.
Just run the script you'll find in Gitorious here: http://gitorious.org/boostoniphone/boostoniphone
Download yourself boost_1_44_0.tbz into the same directory, run the script. Make a cuppa. Make another cuppa. And then admire your new shiney Boost framework.
Use it like any other framework. Draggy droppy. Happy happy.
What changed?
For the hardcore faithful who care about htese things, here's what's changed since my last script version:
- Boost now builds for iOS far more easily (I think this changed for the better in 1.43.0). Now, you just need to write some gibberish in a user-config.jam and run a boostrap script. That is a darned site easier than it used to be.
- To make it build for the simulator, you still need to invent some missing header files.
- But the biggest hassle in this version was creating the final universal library file. Since the ARM builds themselves are now fat archives (including an armv6 and armv7 version of each .o file) I needed to work out how to make a functional uber-lib file. Because Apple's binutils are not useful GNU ones, their ar is braindead. The only way to make a correctly functioning library (that I could find) was to un-lipo the fat ARM binaries, un-ar each archive, link all the original .os into an uber library, than lipo up each of those. Does that sound painful? Yes. It hurt.
Monday, 27 September 2010
Learning: A cunning plan...
In the common work scenario you start from ground zero and need to get up to speed with something in super-fast time. You need to pick up a new codebase, a new set of technologies, and a new problem domain. And be effective and productive almost immediately.
This is rarely possible. But you can be effective fairly rapidly as long as you recognise that you are starting out at the novice Dreyfus level (remember our look at the Dreyfus Model of Skills Acquisition?). In order to be effective at this point you must find a good set of rules to follow, since novices rely on rules to get work done.
But you want to progress beyond novice level, don't you?
In order to learn effectively you need to put in place a considered learning plan. Now, if I wanted to get from my home in Cambridge to visit a friend in Inverness, I wouldn’t just jump in the car and set off. I’d need to plan a route first. I wouldn’t even set up my satnav and follow its instructions. Should I really trust a device to know best?Does it know how I prefer to travel, any particularly busy roads at this time of year, which roads the authorities have decided to perform military assaults on today, etc? Similarly, does a teacher know better about how to get me from here to knowledge?
So I'd have to carefully plan a route first. Maybe getting in the car isn’t actually the best way to get to Inverness – perhaps I should instead fly there, and hire a car at the other end.
Put in place a deliberate learning plan.
So how might we apply this practically to our learning? Start by recognising exactly what you do know right now. Determine what you need to know. Weigh up the possible routes to get there: books, courses, web research, podcasts, etc.
Then determine two or three waypoints along the way you can purposefully aim for. Don't aim too far into the future, as once you have learnt more you may need to re-plan your learning route. Work out how to learn enough to get to those first waypoints. Work out exactly how you'll know when you've got there. (Consider this Test Driven Learning – work out some tests (katas, specific tasks, etc) that will prove you know something. You can use these same tests in the future to check for regressions in your learning). Then once you have a specific plan in place, begin learning.
Planning and executing a learning journey will make your work more focussed and directed. It may prevent you from wasting time by browsing for far too general information on the web, or reading all of a book when only two chapters in the middle are relevant.
Friday, 17 September 2010
Learning: Some How-Tos
Continuing my blog series on software developers learning, I'm going to look at some of the tools available to help us learn most effectively.
Using tools
So what tools are available? When I ask at conferences what the best learning tool is, without fail someone immediately says "The Brain". However, that is not the right answer.
As strange as it sounds, the most potent and powerful tool we can employ is the entire human body. A human being is a large interconnected system, the brain is important, it's our CPU, but it's connected and influenced heavily by the rest of our fleshy substance.
We'll see how the whole body is important and can be exploited to help us learn more effectively.
The little grey cells
But let's start by focussing on the brain. Sadly, we’re not really ever given a user’s manual for the brain. (And even if we were, most men wouldn’t read it anyway...)
Firstly, we must keep this thing well prepared mechanically. Use the correct fuel: enjoy a healthy diet and make sure you keep well hydrated. It is said that the best brain foods are protein-rich foods such as meat, fish and cheese; these are good sources of amino acids. Also ensure you give yourself a good supply of the appropriate vitamins and minerals (vitamin B, sodium, potassium, and omega-3 are all said to be important for brain function). To keep your brain working at it's top condition (and let's be clear – to be an effective developer you really should consider how to keep your brain working as well as you can) you should pay attention to this kind of thing.
Other very obvious basic brain mechanics are to get plenty of sleep and avoid as much stress as possible to enable you to be less distracted and better able to think. It sounds glib advice, but how often do you consider how continual stress or burning the candle at both ends affects your effectiveness?
Using all of the brain
In a previous blog entry we investigated the left/right brain modes. Most developers lean towards left-brain modes of thinking, so to maximise use of our potential brain power we need to learn to dial down the left side of our brain to give the right side a fighting chance. Otherwise we'll only exploit half of our potential learning power.
Do remember, though, that both modes of thought are essential. We really need to work out how to get both brain modes to work in concert. In order to think and learn effectively we must be able to bring both “sides” of our brain into use.
There are some very basic documented ways to stimulate the right side of your brain. Cross-sensory feedback will stimulate parts of the brain that we don't normally exercise. Consider trying some of these actions whilst learning:
listening to music whilst you work,
doodling whilst you think (yes I am paying attention in your meeting, look at how many doodles I've made...),
fiddling with something (a pen or a paperclip, perhaps),
talking whilst you work (vocalising what you're doing or learning, it really does help you retain more knowledge),
making thought processes concrete rather than purely intellectual – like modelling things with building blocks or CRC cards,
meditative practices (many help you attain greater focus and cut out distractions)
These actions can help to invoke the right brain whilst performing activities that you might naturally focus more on left-brain operation. Each of these expand sensory input and serve to activate more neural pathways than normal.
Multiple input, maximal output
Different personality types learn in different ways. I can’t prescribe the best method of learning for everyone. However, try to learn a topic by absorbing information from many different information sources. In this modern connected world we're presented with many media forms:
The written: e.g. books, magazines, blogs.
The spoken: e.g. audio books, presentations, user groups, podcasts, courses
The visual: e.g. video podcasts, tv shows, performances
Some people will respond better to particular media. What works best for you? For the best results mix several of these sources. Use podcasts on a topic to reinforce what you're reading in a book. Attend a training course and read a book on the topic, too.
Use as many input types as possible to maximise your learning potential.
Take note
Whilst learning grab a notepad and capture information as you uncover it, rather than let it wash over you.
This serves two purposes. Firstly, it keeps you focussed and helps you to maintain concentration on the topic. It's a basic idea, but remarkably helpful. Secondly, even if you throw those notes away immediately afterwards, the cross-sensory stimulation will aid your recall of facts.
Takes notes as you learn. Even if you throw them away.
The practice of learning
Our key to learning is to pay attention to the practice of learning. Here I'm not using the noun practice. No, learning is an activity; unless you remain consciously and actively involved you will not learn effectively. Learning without practice, without applying the new knowledge, will not lead to deep understanding or long-term recall. We need to perform what is known as deliberate practice (Self-theories: Their role in motivation, personality and development (1999) Carol S Dweck. ISBN-10: 1841690244)
It is perfectly possible to perform pointless practice; to not pay full attention and waste your own time and effort. I'm reminded of some high-school recorder lessons that I was subjected to (ooh, many years ago now). This class was dumped into a room, each given a “learn the recorder” book, and expected to get on with it. It's true that that teaching method does leave a lot to be desired. And it's obvious that a group of kids that don't care at all about playing recorder will never learn to play the recorder. There was no motivation, a failing attitude.
But more importantly, a thirty minute lesson where no one is paying attention or trying to deliberately learn will never lead to learning. At the next lesson all the kids started back at page one again; they'd forgotten everything they'd read previously. There was no actual learning taking place in those lessons. A whole term saw very few people progress beyond the first half-hour of the teaching plan. The lessons were literally a load of hot air. And raucous screeching sounds.
Learning without doing is a fruitless task.
Ensure that your learning regimen involves mindful practice. Powerful techniques to consider here are Coding Katas and Coding Dojos. Katas were introduced into the development worlds by Dave Thomas of pragmatic programmer fame. A kata, like its martial arts synonym, is a small task or process that a student can repeat deliberately in order to learn a skill. Perhaps a simple coding exercise or refactoring task. Coding Dojos are meetings where programmers gather to perform katas together. Specific, deliberate learning meetings.
Dojos are becoming increasingly popular. Jon Jagger and Olve Maudal ran an excellent Dojo at this year's ACCU conference, for example. Follow the link for the software system they developed to run it.
If the brain is the CPU of our learning machine, then we should consider other uses of the machine that will aid learning. In the modern world, few computers are an island. Networking is an essential learning aid. The social context enhances our learning, and adds accountability (aiding attitude) and greater interactivity (aiding deliberate practice and cross-sensory feedback).
These are all invaluable social learning practices:
pair programming
study groups
mentoring and teaching (by teaching others you solidify your knowledge, you are forced to learn more yourself, and as you see a newbie begin to gain a wider picture you will realise flaws in your own knowledge, or see foundational knowledge in a fresh light that will be really beneficial)
writing articles (for magazines, for the web, for blogs)
discussion (perhaps in the pub)