mobiletuts: Learn Objective-C (Series)

I picked up a new MacBook Pro from Amazon.com in April (2011) with the intention of learning Objective-C to write iOS and Mac software, but made little progress with any of the tutorials I found, until I found this series on mobiletuts:

http://mobile.tutsplus.com/series/learn-objective-c/

I think the thing that kept me away from understanding Objective-C until now was the strange look of the significantly different syntax used in Objective-C, as compared to languages I’m familiar with like C#, Java, JavaScript, and C/C++. Objective-C syntax is derived from Smalltalk, in which one sends a message, as opposed to the more common Simula-derived languages, where one calls a function. (More detail on this concept can be found on Wikipedia here: Objective-C: Messages).

In other words, code like this (C#) looks familiar:

public interface SimpleCar : Object
{
  // Public Accessors
  public String Make { get; set; }
  public String Model { get; set; }
  public int Vin { get; set; }
  // Not really necessary, since we already have an accessor...
  public void SetVin (int newVin); 

}

…while this (Objective-C), until recently, looked incredibly foreign and confusing:

@interface SimpleCar : NSObject {
  NSString* make;
  NSString* model;
  NSNumber* vin;
}

// set methods
- (void) setVin:   (NSNumber*)newVin;
- (void) setMake:  (NSString*)newMake;
- (void) setModel: (NSString*)setModel;

// convenience method
- (void) setMake: (NSString*)newMake
         andModel: (NSString*)newModel;@end

Unfortunately, despite sincere interest and significant motivation, most of the Objective-C guides I came across were too dense, too verbose, or not particularly interesting. So, my MacBook got a ton of use as my primary home computer (I’m an ASP.NET software engineer by day, and I use Windows exclusively at the office, but I do love me some OS X…), but Xcode gathered dust in my dock, and I went about exploring alternatives that used a more familiar syntax – like the Qt SDK (C++), MonoDevelop (C#), and NetBeans(an impressive array of different languages).

Now that the back story is out of the way, here’s why the mobiletuts Objective-C series turned that all around and actually got me to *enjoy* developing with Objective-C:

  1. It’s very simple.

    While I do have an extensive background in software engineering, I appreciate guides that break concepts down to their simplest parts and rebuild them slowly, with no assumption of the reader’s background (other than interest in the topic). For most of you who already know your way around another language and who are familiar with the Terminal, the first lesson (Day 1) will seem almost too basic, but stick with it, because you’ll find that the author, Dan Walker, really knows his stuff. His approach reminds me of a quote from commonly mis-attributed to Einstein: “If you can’t explain it simply, you don’t understand it well enough”.

  2. It starts with what you know.

    I didn’t fully realize this from reading other sources about Objective-C, but it really is a strict superset of C. The benefit of this fact, for developers familiar with Simula-derived languages (C#, C++, Java, etc.) is that you can start writing Objective-C code in a syntax you’re familiar with (C), then sprinkle in bits of Objective-C syntax slowly, while you become more familiar with its Smalltalk-derived syntax. For instance, this code is valid, and compiles successfully in Xcode – Notice the use of Objective-C syntax within a familiar C-style method. (This clip is from the Day 3 post.):

    #import <Foundation/Foundation.h>
    
    int main (int argc, const char * argv[]) {
    
      NSString *testString;
      testString = [[NSString alloc] init];
      testString = @"Here's a test string in testString!";
      NSLog(@"testString: %@", testString);
    
      return 0;
    
    }
    
  3. It’s actually interesting.

    Dan has a great conversational style to his posts that make them very accessible and compelling, while slowly introducing increasingly complex topics. In Day 1, he explains how to open the Terminal app and invoke gcc from the command line, and by Day 2, he’s provided a great synopsis of  the benefits of concepts like encapsulation, abstraction, and inheritance.

I’m nowhere near an expert on Objective-C, since I literally (yes, literally) started reading this article yesterday, but I feel confident enough in what I’ve learned from this article to start poking around in Xcode and trying to refactor some of my existing code into a working Objective-C implementation. I hope this article helps you as much as it’s helped me, and please, let me know what you think by posting in the comment section below.

Happy coding! =)

the hamstu » The Typography of Code

fixed_prop.png

Cool post with a lot of great history and font samples!

As a self proclaimed programmer/designer I enjoy not only the logical and practical things in life, but also the beautiful and well designed. And I find the greatest pleasure when these things converge to produce something extraordinary.One such thing is Typography. Typography is the art of language, the visualization of the spoken word. A medium by which non-verbal communication is made possible. And though I profess no expertise in this art, I have come to deeply appreciate it’s power and ability to convey the same message in so many different ways. Each with a unique feeling and style.

The Messenger

In 1956 Howard Kettler designed the typeface Courier. It was made for IBM’s new (and revolutionary) line of electric typewriters. Originally called “Messenger”, Courier is one of the earliest fixed-pitch (also known as Monospace) fonts, meaning each character takes up the same amount of space on a line; allowing for easy tabular alignment and legibility.

Courier was a hit, and as many made the transition from typewriter to computer, this classic typeface wasn’t far behind. It was included in all early Apple computers, and while creating the core fonts for Windows 3.1, Microsoft hired Monotype Typography to give Courier a makeover. And so Courier New was born, as a thinner and cleaner version of it’s former self.

via the hamstu » The Typography of Code.

Top 10 Tips For New Eclipse Users | Ben Pryor’s blog

Great tips for Eclipse users; I really could have used these for my last Java project:

  1. Use Code Assist
  2. Navigate Through Code By ctrl-Clicking
  3. Quickly Open Classes and Resources by Name
  4. Know the Keyboard Shortcuts
  5. Set the Heap Size
  6. Configure Eclipse To Use a JDK, not a JRE
  7. Use the Eclipse’s Refactoring Support and Code Generation
  8. Use Multiple Workspaces Effectively
  9. Use Templates
  10. Set Type Filters

Find the details on these tips here…
Top 10 Tips For New Eclipse Users | Ben Pryor’s blog.

Flickr Batch Download Tools

It surprises me that good flickr batch downloading tools are so hard to find! I’ve been on a kick lately, per suggestions from flickr advice articles, to archive and remove my point-and-shoot shots from my flickr photostream so that I can focus on my more artistic work.

To this end, I’ve been looking for a good tool to download my old photos, and have found three good candidates:

1. FlickrEdit (Java)

FlickrEditSunkencityHeader

From the looks of this application, it *should* be the one-stop shop for all of your flickr downloading needs, but for some reason, it consistently failed on my machine. After about twenty failed attempts, I gave up. Hopefully this is just a small bug, but I got dissuaded from using it very quickly. Nonetheless, it looks like a solid app, and it’s probably worth a look. (Please let me know if it works for you, and which version of Java you have installed – I can’t figure out what was wrong with it.)

2. Flump (Adobe AIR)

2742770656_8401a25013_o

Flump is a super lightweight, no-nonsense photo downloading tool. You just give it an account, a location to download, and a file mask. It will download all of the photos from that account. The downside? It will *only* download all the photos from that account. If you’re trying to only back up a selection of your flickr stream, you’ll have to wait until the downloading sequence gets that far. But, it’s still worth a look because it’s just that easy to use.

3. FlickrDown (Windows/.NET 2.0)

flickrdown-ui

FlickrDown is by far my favorite of the bunch. It’s super simple to use, gives you a great selection of your sets (and allows you to choose all your photos), and is quite solid. This is well worth the small download. Windows only, though. (Or, you might be able to rig it to run on Mono.)

Update: Just found this via Lifehacker: Flickr AutoDownloadr. Haven’t checked it out yet, but it looks promising.