jump to navigation

Program Development By Step-wise Refinement 26 April 2009

Posted by Oliver Mason in Apple, iphone, objective-c, programming.

DAY 5, and I’m making my first steps in Objective-C, other than keying in sample programs and trying little things out. It’s been such a long time since I had to worry about memory management, though it looks relatively easy, compare to original C. Still, would be better if one didn’t have to worry about it.

After I got into the Erlang mind-set with my most recent programming, I need some time to get back into C. I’m following a methodology I picked up more than 20 years ago, Wirth’s 1971 Paper on Program development by stepwise refinement, at least as much as I remember it. I haven’t read it since about 1990 I think. Basically you formulate your program in pseudo-code, and step-by-step get closer to actual code.

My first refinement step was to create a Stack class, which is little more than a wrapper around a NSMutableArray with just three methods: push, pop, and isEmpty. Trivial, but useful to practice getting used to the way things work in Objective-C. There is a lot which seems to be based on conventions, such as the names of mehtods which get called under the hood at various stages. Luckily there is plenty of material on the web to help you pick those things up!

As for my first app-project, a morphological analyser, I’m slowly getting there. The main part is probably about 50% coded, and the lexicon-lookup routine is still missing. I guess I’ll opt for a sqlite database here, seems like the most effective way to access that kind of data. But I’ll cover that in a later post.

Oh, and here is the reference for the Wirth paper:

  • Wirth, Niklaus (1971) Program Development by Stepwise Refinement, in Communications of the ACM, Vol. 14, No. 4, April 1971, pp. 221-227.

On-line versus Paper 22 April 2009

Posted by Oliver Mason in Apple, iphone, programming, Uncategorized.
add a comment

DAY 4, and the textbook I ordered arrives from Amazon. (I’ll skip days on which I don’t do anything iPhone-dev related). The book looks good, and I now finally understand more about the connections between InterfaceBuilder and XCode. And why my attempts at displaying stuff in an UIWebView didn’t work: it’s all in the connections between interface components and variables in the code. Using graphical tools when you’re not used to them can be tricky.

This I think is the most important aspect in all this: previously my development environment (for pretty much the past 15 odd years) was vi (actually, vile) and a command-line version of either gcc or javac. I am so not used to IDEs, and all the things you won’t find in files. But I have to admit that using IB can greatly speed up the process of laying out applications.

On the telly and web I hear more stories from people making a killing with iPhone apps. Nice, though I have no illusions, as the kinds of things I’d be working on are fairly niche-type products. And I don’t even know how far I get, as I’m only doing it in my spare time. If it becomes too time-consuming I will probably not get very far.

Still, it would be nice to have a finished product in the App-store!

The book, btw, is an easy read. And apart from learning about the iPhone itself there is also a lot of getting used to the Mac style of doing things. Somehow a completely different world. And Objective-C has its own idioms. And on the iPhone there’s no garbage collection– that was always one of the biggest arguments for abandoning C++ in favour of Java, no more segmentation faults. Much fewer bugs, a whole category of them wiped out without any extra effort on my part. So back to manual transmission we go.

The main question when buying Beginning iPhone Development for me was whether it was going to be worth it. And given my lack of experience of developing for an Apple platform I’d say it is. And having it all in front of you in a book is still better than trying to find it yourself on the web, even if all the information is out there somewhere. Books are still more convenient than electronic documentation, at least for textbooks; reference material might be different.

A New Platform… 18 April 2009

Posted by Oliver Mason in Apple, iphone, programming.


After playing with my latest gadget (an iPhone) and looking at what’s on offer at the App store I was beginning to wonder whether I could start a side-line as an iPhone-developer myself. There are some things I’d like to do with it for which there don’t seem to be apps readily available, and I also have some ideas for useful tools which other people might even be prepared to shell out a few pennies for. Not that I think they’ll be bestsellers, but with large numbers of people looking at low-cost software there must be some chance for a few sales world-wide.

So off starts The iPhone Project. Having read some people’s stories about developing software on it, it doesn’t seem to bad. And, I don’t have to sell lots of stuff as I don’t depend on the income. Some smallish contribution to the cost of the monthly contract would be useful…

However, you need to invest first: the iPhone SDK only runs on Leopard, while I’m still on Tiger. And then there’s $99 per annum to pay to Apple. But I think I’ll pass on any reference books, as there seems to be quite a lot of on-line material available. And Objective-C doesn’t look too scary either.

First step: ordering the OS upgrade.

I spent the best part of a day trying to make a full backup image of my drive in case something goes wrong–external USB drives are solo slow if you’re shifting dozens of gigabytes around. The ordered Leopard DVD arrives at 15:30, but I still need until about 23:00 before my computer is ready.

If all goes well, the upgrade will have finished just before I actually fall asleep, so getting my iPhone to say “hello world” has to wait for another day.

It did, though it took until 1:00 in the morning. And the next day is spent playing with the iPhone SDK. I do get the obligatory Hello World running, but my attempt at app #1’s interface fails miserably. I can’t tell the UISearchBar not to capitalise and auto-correct the input, and the output (richly formatted text) was meant to be displayed by a UIWebView which remains conspicuously blank.

More frustration, as I cannot for some reason subscribe to the iPhone Developer Programme. The Website does seem to have some problems with my FF browser, and Safari no longer works due to the upgrade to Leopard. I try to download Safari from the Apple Website, but that doesn’t work either. Finally I use my iPhone(!) to enroll, for a cost of about £60 p/a. That should be the main investment sorted, apart from my time.

However, I do begin to wonder whether a textbook on iPhone development would not be a good idea after all… And, just after having written the previous sentence I decide that £20 for a book with consistent 5-star-reviews would probably worth the time I save by tracking down all the info on the web. Amazon, here I come!

So, after three days there is a certain amount of frustration, but also some optimism. And I keep getting more ideas about what kind of apps I might want to write!

Current balance: -£139.40

to be continued…