An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++...

67
An Introduction to Android for iOS Developers Simon D. Levy CSCI 251 12 May 2014

Transcript of An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++...

Page 1: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

An Introduction to Android for iOS Developers

Simon D. LevyCSCI 251

12 May 2014

Page 2: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

DISCLAIMER ...

Page 3: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java
Page 4: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java
Page 5: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java
Page 6: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java
Page 7: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java
Page 8: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

Android vs. iOS: Consumer

Perspective

Page 9: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

(worldwide)

Page 10: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java
Page 11: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

forbes.com

Page 12: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

forbes.com

Page 13: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

UnixNon-Unix

Page 14: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

http://en.wikipedia.org/wiki/File:Unix_history-simple.svg

Page 15: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

Consumer Perspective:

Devices

Page 16: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java
Page 17: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

http://www.digitaltrends.com/

Page 18: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

http://www.cnet.com/

Page 19: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

http://www.cnet.com/

Page 20: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java
Page 21: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java
Page 22: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java
Page 23: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

Samsung T9000

Page 24: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

Google Project Ara

Page 25: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

Developer Perspective:

Distribution Model

Page 26: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

Walled Garden

Page 27: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

Curated Computing

Page 28: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

Wild West!

Page 29: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

Wild West?

http://en.wikipedia.org/wiki/Walled_garden_%28technology%29

Page 30: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

Fee Structure

Page 31: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

Getting your app onto your device: Provisioning

Page 32: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

Getting your app onto your device: Provisioning

Page 33: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

The Power of Open Standards

Page 34: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java
Page 35: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java
Page 36: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java
Page 37: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

Reverse Engineering

Page 38: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java
Page 39: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java
Page 40: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java
Page 41: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java
Page 42: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java
Page 43: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java
Page 44: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java
Page 45: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java
Page 46: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java
Page 47: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java
Page 48: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java
Page 49: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

Developer Perspective:

OS

Page 50: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

http://developer.apple.com

Page 51: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

http://en.wikipedia.org/wiki/Android_os

Page 52: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

Developer Perspective:

IDE

Page 53: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java
Page 54: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

Ancestry: NeXT

Page 55: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java
Page 56: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

Developer Perspective:Language

Page 57: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

CSmalltalk

Objective-CC++

Simula

1960

1970

1980

1990

2000

Java

Page 58: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

Memory AllocatiomC++: Explicit deallocaction

void mymethod(){

Circle * circ = new Circle(3,4,2);…

delete circ;}

Page 59: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

Memory AllocatiomJava: Garbage-collected

void mymethod(){

Circle circ = new Circle(3,4,2);…

} // circ automatically deallocated now

Page 60: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

Memory Allocatiom● Objective-C: Reference counting (“semi-automatic”

garbage collection)

NSString* s = [[NSString alloc] init]; // Ref count is 1[s retain]; // Ref count is 2 - silly // to do this after init[s release]; // Ref count is back to 1[s release]; // Ref count is 0, s is freed

http://stackoverflow.com/questions/6578/understanding-reference-counting-with-cocoa-and-objective-c

● Xcode (4.2 and later) provides Automatic Reference Coutning (ARC), making this largely unnecessary

Page 61: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

Inheritance● C++: Multiple inheritance

class Apple : Fruit, Edible{

};

● Experienced programmers avoid this, using composition (has-a) instead of inheritance (is-a).

Page 62: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

Inheritance● Java: Single inheritance + interfaces

class Apple extends Fruit, implements Edible{

}

Page 63: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

Inheritance● Objective-C: Single inheritance + protocols

@interface MyClass : NSObject <MyProtocol>

...

@end

https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/WorkingwithProtocols/WorkingwithProtocols.html

Page 64: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

Method Invocation C++, Java

● Invoke an object's method● “Tight” association between method

and class ● Compiler makes sure that class

implements method

circ.move(-3,5);

Page 65: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

Method InvocationObjective-C

● Send a message to an object● “Looser” association between method

and class ● Object can ignore message (runtime

constraints; programmer didn't implement method)

[circ moveX:-3 andY:5];

Page 66: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

Reflection

● Java: We can query the type (class) of an object at runtime:

System.out.println(c.getClass());

Page 67: An Introduction to Android for iOS Developers · 2019. 1. 14. · Smalltalk C Objective-C C++ Simula 1960 1970 1980 1990 2000 Java

Reflection● Objective-C: We can also check which

messages the object responds to:

http://stackoverflow.com/questions/4574465/objective-c-respondstoselector-question

if ([c respondsToSelector:@selector(move:)]){

}

if([c isKindOfClass:[NSString class]]){

}