Tue 18 Apr 2006
Cocoa Notifications and its importance to application design
Category : Technology/LucaNotification.txt
I would like to elaborate a bit more on what I wrote in the previous post, on the relation between technology and business needs.
Cocoa has a construct called notifications and it works like this : If any part of an application needs to be informed of an event that happens anywhere else in the application, it can register its interest with a Notification Centre. Then you can code your application such that when such events occur, you post a notification to the Notification Centre, who will forward that notification to all parties (and only those parties) who had expressed interest in it.
So, in a real world case, it works like this :
In the Accounting System, you may be looking at your Current Assets, which includes a Debtors' list. Then, from another window, you may be creating a Receivable Voucher for a particular debtor. If you happen to be also monitoring that debtor's list of transactions, its totals will be updated as soon as the data entry for that voucher gets completed.
If you're looking at the totality of all your transactions under Revenue, that figure will also get updated.
Switching back to the point of view a programmer, it's very hard to do this type of coding on your own - unless you hit upon the idea of having a Notification Centre to centralise, coalesce and dispatch all the notifications in an orderly way, which I thought was brilliant when I came across it because I had been doing this type of programming on my own and they were often a mess.
And look at the economics of the situation. It's a nice-to-have feature. So the amount of time you spend programming it should be kept in proper relation to the amount of code that really does the dog's work in the application. In other words it shouldn't be carrying too much weight, otherwise it would be like the tail wagging the dog. But what it gives your application, if you get it right, is a feeling of omniscience, and you know how God-like that feels.
So that's what the Notification Centre, and lots of nice touches in the rest of Cocoa, does - it tips the economics in the favour of the creative programmer, by making it possible to do this in the time you are allowed to allocate to it.
So, if you're a business owner and you hear your IT manager saying that he won't accept a language like Objective-C or a tool-set like Cocoa - "who has heard of it" and he can "pick up a Java or Visual-Basic programmer from any street corner" - rest assured that that street-corner programmer hasn't spent any time thinking through the economics of programming or scoured the world for the best programming tools to build the best business applications on.
That's the fight we are in. If we had stayed in organisations we'll never have been allowed to do this. There is a world of Mac users out there. There's no time to spend debating the issue. There's work to be done and let's just do it.