Monthly Archives: July 2008

 
29
Jul
2008
 

Cocoa Tutorial: Windows OOP vs Cocoa MVC

by Matt Long

Encapsulate everything! Right? Or not. I was watching the Cocoa developers email list today and saw a post asking for help getting two views to communicate between one another. Having been a Windows programmer for longer than I’m willing to admit, I recognized the question as it was one that I also had when I moved to Objective-C on the Mac. I think I can ask the question more succinctly now than I could then. Better phrased it would be “I have a dialog object that I instantiated and obtained some data from the user with it. I now need to get that data out of my dialog object back into my main window object where I can do something with it. How can I get the information back into my main window from the dialog?”

In Windows, more specifically C# .NET, you would create a new window by adding a Windows Form object that you could then edit with the designer adding various controls pretty easily. But once that window was created, you now need to create an instance of it in your main window code and then provide public accessors to assign or obtain data between the two windows. The window class generated by the Windows Form template encapsulates everything for you. It certainly makes the code look clean, but it really breaks the Model View Controller paradigm so it’s no wonder Windows programmers (myself included) have a hard time shifting their way of thinking.
(more…)

 
9
Jul
2008
 

A git quickie

by Marcus Zarra

After reading Fraser Speirs’ excellent write-up on his conversion over to git, I followed a few of the links to find a bash script to display your current git branch in the command prompt. Following yet another link from that post showed how to convert the bash script to zsh.

Here is my contribution to move that from the prompt to the right side of the screen.

function parse_git_branch {
  git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
function precmd() { RPS1="%~$(parse_git_branch)" }
export PS1='> '

Note that the last line just gives me a very short left hand prompt which I prefer.

GitBranchDisplay
Uploaded with plasq‘s Skitch!

 
8
Jul
2008
 

A Case Against Dot Syntax

by Marcus Zarra

I was not born an Objective-C developer. I know that in some circles that is considered a mortal sin. Before learning Objective-C and Cocoa I had developed in a great number of languages dating back to the early 1980′s. I tell you this so that what you are about to read next is taken in the light that it was intended.

Take a look at the following lines of code:

- (void)doSomethingSpecial
{
	myVar.itsAttribute = 10;
	myOtherVar.itsAttribute = 20;
}

Now tell me, what is myVar and myOtherVar. Is it an object or a struct? Can’t tell from that piece of code can you. That is half of my argument against dot syntax in Objective-C. It makes the meaning of your code unclear. Objective-C is known for its self documenting nature. Dot Syntax removes that.

(more…)

 
8
Jul
2008
 

The audacity of [some] Windows Developers

by Marcus Zarra

Thanks to our beloved iPhone (I do refrain from calling it “My Precious”), we have seen a sudden influx of Windows Developers. Now, when most of us came over to OS X and Objective-C from whatever platform we hailed from we did not assume that everything would be the same. Most of us are reasonable people and realize that OS X is different for a reason. Unfortunately, it appears that we are unusual people. Perhaps this would explain why we came over to this platform before it became “popular”.

With this recent influx of developers, most of whom we have welcomed with open arms, there are some who expect everything to be the same as the platform they came from and without bothering to learn or experiment have proclaimed our development tools to be “prehistoric”. This truly amazes me.

First, welcome to OS X and iPhone development. This is not the same language, platform and API you have been dealing with. Accept that or go home. We are not going to change it to suit you. We like it just the way it is.

We do things differently over here. Accept that or go home.

You have an interest in either OS X or the iPhone. To do a proper application for either one (barring a few edges cases), you need to learn Objective-C and Cocoa. Accept that … well you get the idea.

Objective-C has been around for a long time and it is a well thought out language. It is a runtime focused language and therefore things work differently than you are used to in your more structured environments.

Most of the time when these so called developers complain about Objective-C I simply roll my eyes and walk the other way. It is the sane thing to do. Never wrestle with a pig — you get dirty and the pig likes it. However, one particular “genius” has decided to out himself on his own blog. Of course I speak of none other than Jesse Ezell.

It is clear from this blog post that he has no interest in learning why OS X, Cocoa and Objective-C are different from his beloved Visual Studio but instead cries that it is too hard. I mean, seriously, complaining about NSObject vs Object? Perhaps he did not bother to learn that there is more than one root object in Objective-C? And then go to on and complain about MVC like its the devil’s music? Hopefully he is not the best that .net has to offer us!

But even with all of that, I read his post, chucked and moved on. It was not until he responded to the comments on that post that I decided to respond. It seems, from his perspective, that if a developer cares enough about their development environment to respond to his rant (and try to educate him!) that we are all “rabit elitists” out to get him!

First the word is rabid, not rabit. If you were using OS X you could have seen that it was misspelled and used the dictionary to figure out what the word meant. If you can’t even bother to run a spellchecker why bother writing at all?

Second, we care about our platform. We care about the code that we produce and how our applications look and are presented to the user. I know that is probably an extremely foreign concept where he comes from. But we care!

When developers come over here with preconceptions they do everyone a disservice. If they cannot even be bothered to pick up a book and read about the language to understand its fundamentals and its tools then why bother complaining about it. They are a waste of space. Move over and let someone who is willing to learn step up to the plate.

As for this developer’s ego and contempt for the developers on this platform — shame on him. His arrogance speaks towards his ignorance. He probably has written more lines of code in the past few years than I have. I have found that applications on Windows tends to take ten times as many lines of code as the same application would written on Objective-C and Cocoa. That does not make this developer better — if anything it makes him worse.

My suggestion is this: Pick up a book and read. You can even just read blogs like this one and avoid having to pay any money to learn. If a developer can’t be bothered then go home, we have no interest in you and certainly have no need for you.