Your SlideShare is downloading. ×
iPhone development from a Java perspective (Jazoon '09)
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

iPhone development from a Java perspective (Jazoon '09)

485
views

Published on

Based on experience gained in developing the popular Zurich train/tram/bus/ship timeplan transport application, wemlin, senior software engineer Ognen Ivanovski describes development for the iPhone …

Based on experience gained in developing the popular Zurich train/tram/bus/ship timeplan transport application, wemlin, senior software engineer Ognen Ivanovski describes development for the iPhone from the perspective of an Enterprise Java developer - covering aspects about differences in the language, the architecture, the user experience, the tools, and the market.

Published in: Technology

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
485
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
6
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • Where do I work, experience
  • make jokes about ridiculous data roaming charges blatant commercial
  • maybe more details about this...
  • (performance of a unix workstation 10 years ago) - fast startup - use for few seconds, switch off - start where you left off - fingers are fat, not mouse - people wear glasses (paraphrase) - no man pages, no manual
  • Joke: “lets get this behind us”
  • Image of tools / technologies involved, a diagram that will be used throughout the presentation
  • the UI designer is an inegral part of the system
  • also enthusiasm not finished
  • perhaps with some images talk about unix scripts; compare with java - cost of abstracting away the OS Demo here?
  • Demo - not finished - parallel to smalltalk
  • screenshot
  • talk about syntactic vs. semantic similarities what does this mean for a java developer
  • ... of the standard library (very annoying and hindering) (i learned java by looking at the standard library sources)
  • Close up the first impressions; intro about the platform and the langauge; old, been a while
  • will talk about differences more than about similarities
  • 2 things to remember; method call a.k.a. sending message syntax parameters embedded in the method signature verbosity. mention similarity to java in terms of references vs. primitives mention class objects, string literals,
  • compiler here when you need it dynamic productivity
  • Mention null-safe handling .?
  • mention that we usually don’t use a prefix for the main application
  • - talk about argument passing here - verbosity
  • you can inherit constructors
  • talk again about the dynamic nature of Objective-C
  • NSString is usually the prime target e.g. UIKit adds drawing methods to the string class splitting a class into parts Visible when you compile / link against the framework that adds it
  • compare with java
  • THE biggest issue: - difficult to comprehend - constant cause of trouble - the source of almost every nasty bug we had
  • wrapup
  • Give a short talk about patterns in CocoaTouch. put an image
  • events - UI events chain of command
  • Compare to SAX parsing - handler - events (notifications) Extending through delegate instead of inheritance/composition one-to-one events
  • Transcript

    • 1. Development for the iPhone from a Java Perspective
      • The Tools, The Language, The Experience
      Ognen Ivanovski Netcetera 9140
    • 2.
    • 3. Background
        • Software Architect; @Netcetera since 2001
        • 2000 - present: Java (enterprise, web, swing, RCP)
        • 2008 - present
          • Mobile Development: Android, iPhone OS
          • Technical Lead for Wemlin
    • 4.
        • iPhone App
        • Covers the Zürich greater area
        • See departure times for public transport
        • Completely offline app
        • Database holds roughly 1.2M records
          • but it’s fast
        • http://mobile.netcetera.ch/wemlin
    • 5. Switching
        • Team of four developers
        • Published 1.0 of Wemlin (then Tramdroid) on October 3rd 2008
        • 1 - 3 weeks adaptation time
        • 1st internal build after 4 weeks
    • 6. New Priorities
        • Performance
        • Start-up time
        • UI
        • Simplicity
    • 7. F.A.Q.
        • No, you can’t use Eclipse for development
        • No, you cannot use Java either
        • Yes, you do need a Mac (Intel based)
        • iPhone SDK
          • http://developer.apple.com/iphone
          • xCode enhanced with iPhone specific frameworks and tools
          • Registration is free, you can download, develop & test in the simulator
            • a fee is required if you want to test on the device and to distribute
    • 8. The Stack
        • OS X (FreeBSD, Mach 3)
        • libc (POSIX)
        • Core Services
        • Objective-C
        • CocoaTouch
    • 9. First Impressions: Toolbox
    • 10. First Impressions: xCode
        • Yes, you are going to miss Eclipse
          • Refactoring support in infancy but progressing
          • SCM support is quite poor (NetBeans is comparable)
          • Code browsing is poor
          • No compile as you type
          • Takes some will to switch
    • 11. xCode: What’s Interesting
        • Multi-window support
        • Great documentation browser
        • Extensive documentation (1.5GB)
        • Built on top of OpenSource technologies
          • gcc
          • gdb
          • Unix scripts to enhance (stdin, stdout)
          • in any scripting language
    • 12. Interface Builder
        • Integral part of the SDK
        • Probably the second visual editor I actually use(d)
        • Integrates with xCode
          • information about classes and their features
          • Outlets, actions, connections
        • NIB / XIB files
          • very similar to Java .ser (serialized) files used in the early days of Swing by IDEs
            • Forte 4 Java
    • 13. First Impressions: Build system
        • The same build system is used from both the IDE and command line
          • xcodebuild
          • one project file
          • low build maintenance cost
        • You don’t actually miss maven much
          • Builds are easy to set up and maintain
          • Advice: don’t reinvent the wheel (use the standard tool box)
        • Frameworks
          • no central repository
          • no out of the box “materialization” of frameworks
            • reliance on shared drives to achieve the goal
    • 14. First Impressions: Instruments
        • It’s Just GREAT
        • It’s based on DTrace
        • DTrace is present on the devices too
        • Almost real-time profiling & analysis both in Simulator and device
          • Just “attach” on a running process
    • 15. Objective-C / Java connection?
        • OpenStep API specification
          • Developed jointly by NeXT and Sun Inc. @1993-1994
          • Direct predecessor to Cocoa and CocoaTouch
        • Java (probably) was strongly influenced by Objective-C
          • http://www.virtualschool.edu/objectivec/influenceOnJava.html
        • At least a common Smalltalk heritage
    • 16. One Big Difference No Source Code
    • 17. Should I learn it?
        • NeXT -> didn’t reach a wide audience
        • Macs too (more or less) -> 8% world PC market
      • but
        • Installed base of OS X including iPhones and iPod touches:
          • grown from 25M to nearly 75M in the last 2 years
        • The platform has reached an incredible number of developers and users in the last 2 years
        • Customers asked for it :-)
    • 18. Diving Deeper: The Platform
    • 19. Devices
        • iPhone
        • iPhone 3G
        • iPod Touch
        • iPod Touch 2nd generation
        • iPhone 3GS
      • ARM11 ~ 400 MHz
      • 128MB RAM (~50MB available to an app)
      • Hardware Graphics Accelerator
      • Slightly faster
      • ARM Cortex V8 ~ 600 MHz
      • 256MB RAM
    • 20. Objective-C
        • Shared (Smalltalk) heritage with Java
          • compiled
          • late bound
          • single inheritance
          • one root class
          • Pass-by-reference for objects, pass-by-value for “primitives”
          • camelCase convention
    • 21. Syntax
        • Strict superset of ANSI C
        • Object syntax is borrowed from Smalltalk
          • [object method]
            • instead of
          • object.method()
          • [dictionary setValue:aValue forKey:key]
          • [location setDistanceInMeters:3 from:zurich]
          • [location setDistanceInKiloMeters:3 from:zurich]
          • NSString *s = [NSString stringWithFormat: @"height %2i" , height];
    • 22. Type System
        • Dynamically typed, late bound
          • Sending messages opposed to method invocation
          • messages (selectors) have a type and can be passed around
        • Type annotations are just “hints” to the compiler, can be added after the fact
          • type id is like Object in Java (every object is of type id)
          • you can send any message to an object of type id
        • “ object variable declaration”:
          • NSString *variable = ...;
          • id variable = ...; (id is like void *)
    • 23. Nil
        • You can send any message to the nil object
          • It will always succeed
        • Return value is always with negative semantics
          • depends on the method signature / call site
          • [ nil isCreated] will return NO
          • [ nil numberOfCopies] will return 0
        • Is this good?
    • 24. Namespace handling
        • There isn’t any
        • Prefixes are used instead (2 to 4 letters) on classes and global functions
          • NSString (Foundation, historical, for NextStep)
          • UIView (UI = UIKit)
          • CLLocation (CL = CoreLocation)
    • 25. Classes: MyClass.h
      • #import <Foundation/Foundation.h>
      • @interface MyClass : NSObject {
      • int age;
      • NSString *name;
      • }
      • @end
    • 26. Classes: MyClass.m
      • #import &quot;MyClass.h&quot;
      • @implementation MyClass
      • @end
    • 27. Methods
      • #import <Foundation/Foundation.h>
      • @interface MyClass : NSObject {
      • int age;
      • NSString *name;
      • }
      • - ( id )init;
      • - ( id )initWithName:(NSString *)name;
      • + ( id )myClassWithName:(NSString *)name age:( int )age;
      • - (NSString *)name;
      • @end
    • 28. Methods: implementation
      • #import &quot;MyClass.h&quot;
      • @implementation MyClass
      • + ( id )myClassWithName:(NSString *)name age:( int )age
      • {
      • return [[MyClass new] autorelease];
      • }
      • - (NSString *)name
      • {
      • return name;
      • }
      • @end
    • 29. Selectors
        • The message
        • Dynamic invocation
      • SEL notification = @selector (jobDone:);
      • id callback = // ...;
      • [callback performSelector:notification withObject:result];
    • 30. Instantiation
      • MyClass *instance = [[MyClass alloc] init];
      • // same as
      • MyClass *instance = [MyClass new ];
    • 31. Protocols
      • #import <Foundation/Foundation.h>
      • @protocol StateHandling
      • - ( void )handleState:( id )state;
      • @optional
      • - ( id )provideState;
      • @end
      • #import &quot;StateHandling.h&quot;
      • @interface MyClass <StateHandling> : NSObject {
      • // ...
      • }
      • // ...
      • @end
    • 32. Protocols
      • id <StateHandling> handler = // ...;
      • [handler handleState:aState];
      • if ([handler respondsToSelector: @selector (provideState)]) {
      • id newState = [handler provideState];
      • }
    • 33. Categories
        • Every existing class can be extended with new methods using categories
          • open classes
          • limitation: no instance variables can be added
        • Used quite often
    • 34. NSObject
        • The main root class
        • Methods:
          • class
          • superclass
          • description (toString)
          • hash
          • isEqual:
          • isKindOfClass:
    • 35. Reflection
      • id anObject;
      • [anObject respondsToSelector: @selector (handleTouch:)]
      • [anObject isKindOfClass:[UITableView class]]
      • [anObject isMemberOfClass:[UITableView class]]
      • [anObject conformsToProtocol: @protocol (Copying)]
        • C based API (Objective-C runtime) for full blown introspection
    • 36. Memory Management
        • Manual Reference Counting
        • Autorelease pools
      • anObject = [argumentObject retain]
      • [anObject release]
      • return [anObject autorelease]
        • THE biggest issue we had and still have
          • dangling pointers
    • 37. Objective-C
        • Dynamically Typed, late bound
        • Semantically very similar to Java
          • root class
          • single inheritance
        • Protocols are just like interfaces
          • have optional methods
        • Classes can be extended through categories
        • Classes cannot be nested’
        • Verbose
    • 38. Patterns
    • 39. Application Model
        • SpringBoard
        • Single Running Application
        • Familiar (Swing)
        • Main Thread w/ event loop
    • 40. Key-Value Coding (KVC)
        • A convention similar to the JavaBean convention
          • properties
          • observing
        • A bit more verbose and powerful
        • You get a lot for free
          • automatic observer notification
          • very easy to use
        • Accessor Methods
      • [anObject setName: @&quot;name&quot; ];
      • [anObject name];
      • [anObject isHidden];
    • 41. Notification Center / Events
        • Notification Center
          • broadcast notifications
        • Events
          • user events
          • responder chain
    • 42. Delegate Pattern
    • 43. Target / Action Pattern
        • Interface Builder
          • Outlets
          • Actions
          • Connections
    • 44. MVC
        • extension through inheritance
        • mixed behavior and view construction
    • 45. MVC (classic)
        • views composed out of stock components in interface builder
        • behavior in controllers
        • connections in interface builder (outlets, actions)
    • 46. Take Away
        • A Java developer is likely to feel at his/her uncle’s house on the iPhone
        • Memory management will grow some gray hairs on you
        • Love thy garbage collector
        • Objective-C is a unique, intoxicating mix of high-level language and raw power
        • Scroll speed is important
    • 47.
      • Ognen Ivanovski http://mobile.netcetera.com
      • Netcetera [email_address]