Notes on Lecture 1: Developing iOS7 Apps for iPhone and iPad (Fall 2013) by Stanford University

What’s in iOS7: 4 major layers

Starting from the bottom to top:

Core OS

  • OS X Kernel
  • Mach 3.0
  • BSD
  • Sockets
  • Security
  • Power Management
  • Keychain Access
  • Certificates
  • File System
  • Bonjour

Core Services

  • Collections
  • Address Book
  • Networking
  • File Access
  • SQLite
  • Core Location
  • Net Services
  • Threading
  • Preferences
  • URL Utilities
Media

  • Core Audio
  • Open AL
  • Audio Mixing
  • Audio Recording
  • Video Playback
  • JPEG, PNG, TIFF
  • PDF
  • Quartz (2D)
  • Core Animation
  • OpenGL ES

Cocoa Touch

  • Multi-Touch
  • Core Motion
  • View Hierarchy
  • Localization
  • Controls
  • Alerts
  • Web View
  • Map Kit
  • Image Picker
  • Camera

Platform Components:

  1. Tools: Xcode 5, Instruments
  2. Language: Objective-C
  3. Frameworks: Foundation, UIKit, Core Data, Map Kit, Core Motion
  4. Design Strategies: MVC

Controller-View Communication Types

  • Outlets: Target-Action
  • Delegates: will, should, did type of methods
  • Data source delegates: data at, count

Controller-Model Communication Types

  • Notification and KVO

Card Object

contents
chosen
matched
-(int)match:

Experimenting with the Card class

Since the Card class was created in this lecture, here are some experiments with the Card class in main.m.
10 cards created starting with 0, 1, 2 … 9. A single random card is generated with content range from 0 to 19.

Output 1 (with a match):
2013-11-02 04:33:46.900 Cards[40876:303] New card content: 3
2013-11-02 04:33:46.902 Cards[40876:303] We found a match. Score: 1

Output 2 (with no match):
2013-11-02 04:34:26.295 Cards[40882:303] New card content: 18
2013-11-02 04:34:26.296 Cards[40882:303] Sorry, no match found.

#import
#import "Card.h"

int main(int argc, const char * argv[])
{
    @autoreleasepool {

        NSMutableArray *cards = [[NSMutableArray alloc] init];
        // insert code here...
        for (int i = 0; i < 10; i++) {
            Card *card = [[Card alloc] init];
            card.contents = [NSString stringWithFormat:@"%d", i];
            [cards addObject:card];
        }

        Card *newCard = [[Card alloc] init];
        int randomNumber = arc4random() % (cards.count + 10);
        newCard.contents = [NSString stringWithFormat:@"%d", randomNumber];

        NSLog(@"New card content: %@", newCard.contents);

        int score = [newCard match:cards];
        if (score) {
            NSLog(@"We found a match. Score: %d", score);
        } else {
            NSLog(@"Sorry, no match found.");
        }
    }
    return 0;
}

Developing iOS7 Apps for iPhone and iPad (Fall 2013) by Stanford University

The Stanford University has released a new course “Developing iOS7 Apps for iPhone and iPad by Stanford University” on iTunes 2 days ago, October 31, 2013.

https://itunes.apple.com/us/course/developing-ios-7-apps-for/id733644550

So far, Lecture 1 to 4 has been released. In contrast to the previous semester, this time Paul Hegarty stresses more on the importance of meeting the prerequisites. This is understandable from the viewpoint that the vast amount of topics that will be covered in about 10 weeks. Previous Object Oriented Programming experience is thus paramount. The prerequisites are also especially important if you are an actual student at Stanford and you have to keep up in order to complete the course in 10 weeks.

However for the rest of us non-Stanford students, we can take the course at our own pace. Drilling down on specific classes, branching out to other technologies and object oriented programming techniques to our hearts content. However keeping up with the course does have some satisfaction as you can always look forward to the videos as they come out. So if you want to actually keep up, I highly recommend you drop all other side-learning objectives and dive in and immerse yourself from head to toe on this course.

This series of blog posts will cover all the topics taught in the course as it unfolds with summary of the notes and slides, actual code and experience of taking the course. So we will begin with Day 1, Lecture 1.

Who might this series of blog posts and notes be useful for? 

Someone who is following the course and interested in various experiments to further strengthen the learning process.

Adding a favicon to your Google Site and Blog

We must admit, having our own custom favicon does add to the vanity value of our web properties.

Adding a favicon to Google Sites and Blogger is super easy. Here are the steps:

Create a favicon.ico file

First make sure you have a favicon.ico file. You can generate one for free using online favicon generators. Here is one we have used: http://favicon-generator.org

Adding favicon.ico to Blogger

In the Admin panel, go to Layout -> Favicon (Edit) to upload your favicon.ico. And your’e done.

favicon-blogger

Adding favicon.ico to Google Sites

Go to the Manage Sites screen and click Attachments -> Upload to upload your favicon.ico file. Nothing more to do here.

favicon-google-sites

Now refresh your sites and you should see your favicon in the browser tab or web address area (depending on your browser).

Here’s how the favicon looks like on the Safari web browser:

object-coder-favicon

Restarting MySQL Server on Mac OS X

Tested on:

Type the following at the Terminal:

sudo /usr/local/mysql/support-files/mysql.server start
sudo /usr/local/mysql/support-files/mysql.server stop

This is useful for restarting the MySQL server via the command line on Mac.

How Many Times Should One Rewrite Code?

One should rewrite code for improved performance, structure and design. But how many times? In the beginning my thought was to possibly rewrite code twice. Later I found rewriting my own code three or four times made it better. This lead to very stable code and useful particularly as a library, API or framework. Now my belief is that to properly understand a problem and to produce really great code, it needs to be written half a dozen times to a dozen times!

I am sure a lot of people are laughing at the claim above, I assure you that I am not code challenged. Here’s what Charles H. Moore (Chuck Moore), inventor of the Forth Language has to say about rewrites:

Before you can write your own subroutine, you have to know how. This means, to be practical, that you have written it before; which makes it difficult to get started. But give it a try. After writing the same subroutine a dozen times on as many computers and languages, you’ll be pretty good at it. If you don’t plan to be programming that long, you won’t be interested in this book.

For more information please see: Programming a Problem-Oriented-Language by Charles H. Moore (http://www.colorforth.com/POL.htm)

The more one writes the same code again and again, a few amazing things happen. The code structure gets better. Refactoring improves. Code quality goes up. And most importantly a pattern emerges leading to improved and solid design. The code becomes extremely elegant and beautiful. Highly satisfying to use.

For most commercial projects, rewriting so many times if at all, is course not financially possible. Too many times software gets written, becomes a success, but no one dare rewrite it because of the resource implication to undertake such a task. But if one was to write code for personal projects then nothing is more satisfying than to improve one’s work. It is important not to be afraid to begin from scratch.

Hope this theory does not lead to code obsession. A proof that code rewrite is important and necessary can be proven if you ask yourself a few questions, ask yourself:

  • Am I better programmer today than yesterday?
  • Could my code today be better than what I wrote before?

When I reflect back the answers are always true. So the code that I can write today will always be better. Hence the call for a rewrite!

WordPress.com: Peace of SAAS and Power of Social Networking

WordPress has come a long way since it’s early days of the default green colored theme which is as far as I can remember was way back in 2003. Two of the great powers of WordPress that I appreciate today, aside from it always being open-source are:

  1. the seamless hosting and upgrades that WordPress.com provides
  2. the WordPress Reader feature and the community around it

As a WordPress developer, have spent way too many days working with client site setups, servers, programming and troubleshooting than I’d like to admit. So I appreciate these days the promise of zero-maintenance systems that SAAS provides. Sure, you can’t customize a system a hundred ways like you can when you are yourself hosting it and have access to the codebase, but that’s the price of the peace of mind SAAS brings to the table.

WordPress Reader and the community around it has great potential as a non-trivial social networking platform in my humble opinion. I find article-length posts a more meaningful way to communicate important ideas than other popular social networking tools out there. Of course this is my personal preference but the appeal of well laid out thoughts in well organized prose is far greater to me than random bursts of frequent short messages. I am sure a lot of other people out there also might find this style of communication more engaging. Hope WordPress.com will take it to even cooler levels in the near future.