Objective-C through Java lenses, by Saša Slavnić

1,006 views

Published on

There is no doubt that iOS made Objective-C popular. Naturally many Java developers would like to do some iOS stuff too. After all, another OO language should be no problem for experienced Java guy. I thought like this too, but I soon found my self in a strange and hostile world.
In this talk I'll talk about my first steps in Objective-C, some rookie mistakes and ways to work around them. I am no expert in iOS, so don't expect rocket science - rather some honest advice from a fellow developer.

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
1,006
On SlideShare
0
From Embeds
0
Number of Embeds
170
Actions
Shares
0
Downloads
12
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Objective-C through Java lenses, by Saša Slavnić

    1. 1. Objective-C through Java lensesSaša Slavnić, youngculturesasa.slavnic@gmail.com
    2. 2. PROPAGANDA• Chief Java Architect, youngculture• 10+ years of software development experience• 2+ years of mobile experience (Android, iOS)• Disclaimer: I love programming in Java, keep that in mind when my talk is too much biased towards it Saša Slavnić, youngculture 2 sasa.slavnic@gmail.com
    3. 3. AGENDA• Objective-C syntax• Memory management• Object oriented concepts• The good parts• Instead of conclusion... Saša Slavnić, youngculture 3 sasa.slavnic@gmail.com
    4. 4. BUT BEFORE WE START...• Motivation – Simple: we all want to produce good quality code Saša Slavnić, youngculture 4 sasa.slavnic@gmail.com
    5. 5. OBJECTIVE-C SYNTAX• Welcome back, * symbol• C and Objective-C code can be mixed easily• There are no namespaces in Objective-C• Class is split in .h and .m file• Class is interface, interface is protocol• [] to invoke methods Saša Slavnić, youngculture 5 sasa.slavnic@gmail.com
    6. 6. MEMORY MANAGEMENT• It is super easy to create memory leaks• Complex scheme of memory management – object ownership concept – alloc and dealloc – retain and release – autorelease pools – special conventions denotes object ownership Saša Slavnić, youngculture 6 sasa.slavnic@gmail.com
    7. 7. MEMORY MANAGEMENT• It is easy to break things – too many releases lead to app crashes – not enough releases lead to memory leaks – compiler does not enforce type safety or memory protection• ARC to the rescue! – unfortunately, there is lot of legacy code out there Saša Slavnić, youngculture 7 sasa.slavnic@gmail.com
    8. 8. OBJECT ORIENTED CONCEPTS• Class definition - field, property and method declarations• -> . [] create confusion when accessing or invoking class elements• Methods do not have to be implemented Saša Slavnić, youngculture 8 sasa.slavnic@gmail.com
    9. 9. OBJECT ORIENTED CONCEPTS• There are no access modifiers for methods and properties• Private methods can be simulated, but they can be invoked anyway• There are no abstract classes in Objective-C Saša Slavnić, youngculture 9 sasa.slavnic@gmail.com
    10. 10. THE GOOD PARTS• There are no null pointer exceptions• Functions are first class citizens• Categories - non-intrusive way to add functionalities to existing classes• Protocols - @optional is nice• Apple frameworks are joy to work with, their experience in building great UI really shows Saša Slavnić, youngculture 10 sasa.slavnic@gmail.com
    11. 11. INSTEAD OF CONCLUSION...• Now, this slide was supposed to answer “the” question – Q: As Java developer, should I mess with Objective-C at all? – A: How can I know that?• Instead, a piece of advice – Understand compiler warnings in Objective-C very seriously; they in fact do mean something Saša Slavnić, youngculture 11 sasa.slavnic@gmail.com
    12. 12. THANKS!• Questions? Saša Slavnić, youngculture 12 sasa.slavnic@gmail.com

    ×