SlideShare ist ein Scribd-Unternehmen logo
1 von 31
Downloaden Sie, um offline zu lesen
1
How to become an Android dev
starting from iOS
(and vice versa )
Giuseppe
Filograno
2
Linkedin:
https://www.linkedin.com/in/filograno
Github: https://github.com/filograno
Email: filograno@gmail.com
Twitter: https://twitter.com/filograno
Native Mobile Developer at
Who are you?
how many native iOS dev?
3
how many native Android dev?
how mobile hybrid dev?
What courses?
Developing iOS 11 Apps with Swift
Paul Hegarty
https://itunes.apple.com/us/podcast/developing-i
os-11-apps-with-swift/id1315130780
Developing Android apps
4
Native Mobile
Programming
Languages
5
Languages
6
Swift & Kotlin
7
Constants & Variables
let name: String = "Giuseppe"
var age: Int = 32
8
val name: String = "Giuseppe"
var age: Int = 32
let name = "Giuseppe"
var age = 32
val name = "Giuseppe"
var age = 32
Type inference
Classes
class Person {
let name: String
init(name: String) {
self.name = name
}
}
let aPerson = Person(name: "Giuseppe")
print(aPerson.name)
9
class Person(val name: String)
val aPerson = Person("Giuseppe")
print(aPerson.name)
How to hold data
struct Person {
let name: String
let surname: String
var age: Int
}
let aPerson = Person(name: "Giuseppe",
surname: "Filograno", age: 32)
10
data class Person(val name: String, val
surname: String, var age: Int)
val aPerson = Person("Giuseppe",
"Filograno", 32)
● No inheritance
● Passed by value
● Default initializer
No inheritance and automatically implements:
● equals()/hashCode() pair
● toString() of the form
"Person(name=Giuseppe,
surname=Filograno, age=32)"
● componentN() functions corresponding to
the properties in their order of declaration
● copy() function
Enums
enum Suit {
case spades, hearts, diamond, clubs
func simpleDescription() -> String {
switch self {
case .spades: return "spades"
case .hearts: return "hearts"
case .diamond: return "diamond"
case .clubs: return "clubs"
}
}
}
let hearts = Suit.hearts
print(hearts.simpleDescription())
enum class Suit {
spades, hearts, diamond, clubs;
fun simpleDescription(): String {
return when (this) {
Suit.spades -> "spades"
Suit.hearts -> "hearts"
Suit.diamond -> "diamonds"
Suit.clubs -> "clubs"
}
}
}
val hearts = Suit.hearts
print(hearts.simpleDescription())
11
Extensions
extension Array {
mutating func swap(index1: Int, index2: Int)
{
let tmp = self[index1]
self[index1] = self[index2]
self[index2] = tmp
}
}
var array = [0, 1, 2, 3]
array.swap(index1: 1, index2: 2)
print(array)
// [0, 2, 1, 3]
fun <T> MutableList<T>.swap(index1: Int, index2:
Int) {
val tmp = this[index1]
this[index1] = this[index2]
this[index2] = tmp
}
val mutableList = mutableListOf(0, 1, 2, 3)
mutableList.swap(1, 2)
print(mutableList)
// [0, 2, 1, 3]
12
Extensions
extension Double {
var km: Double { return self * 1_000.0 }
var mm: Double { return self / 1_000.0 }
var ft: Double { return self / 3.28084 }
}
let oneInch = 25.4.mm
print("One inch is (oneInch) meters")
// Prints "One inch is 0.0254 meters"
let threeFeet = 3.ft
print("Three feet is (threeFeet) meters")
// Prints "Three feet is 0.914399970739201 meters"
val Double.km
get() = this * 1000.0
val Double.mm
get() = this / 1_000.0
val Double.ft
get() = this / 3.28084
val oneInch = 25.4.mm
print("One inch is ${oneInch} meters")
// Prints "One inch is 0.0254 meters"
val threeFeet = 3.0.ft
print("Three feet is ${threeFeet} meters")
// Prints "Three feet is 0.914399970739201
meters"
13
Optionals
var aNumber: Int = 42
var optionalNumber: Int? = nil
optionalNumber = 42
optionalNumber?.negate()
optionalNumber!.negate()
var aNumber: Int = 42
var optionalNumner: Int? = null
optionalNumner = 42
val incrementedNumber = optionalNumner?.inc()
val numberPlusPlus = optionalNumner!!.inc()
14
If let
var optionalNumber: Int? = nil
if let number = optionalNumber {
let incrementedNumber =
number.advanced(by: 1)
print(incrementedNumber)
}
optionalNumber?.let {
val incrementedNumber = it.inc()
print(incrementedNumber)
}
15
Lazy Stored Properties
A lazy stored property is a property whose initial
value is not calculated until the first time it is
used. You indicate a lazy stored property by
writing the lazy modifier before its declaration.
class DataManager {
lazy var importer = DataImporter()
var data = [String]()
}
let manager = DataManager()
manager.data.append("Some data")
manager.data.append("Some more data")
// the DataImporter instance for the importer
property has not yet been created
lazy() is a function that takes a lambda and
returns an instance of Lazy<T> which can serve
as a delegate for implementing a lazy property:
the first call to get() executes the lambda passed
to lazy() and remembers the result, subsequent
calls to get() simply return the remembered
result.
class DataManager {
val importer by lazy { DataImporter() }
var data = mutableListOf<String>()
}
val manager = DataManager()
manager.data.add("Some data")
manager.data.add("Some more data")
16
Frameworks
17
UIViewController
Activity
An activity provides the window in which the app
draws its UI. This window typically fills the screen
18
UIViewController/Activity Lifecycle
19
viewDidLoad
viewWillAppear
viewDidDisappear
viewWillDisappear
viewDidAppear
IBOutlet, IBAction vs ...
Outlets provide a way to reference interface objects from source code files.
An action (or an action method) is a piece of code that’s linked to an event that can
occur in your app.
20
… vs findViewById, listener
21
Autolayout
Constraint Layout
22
Asset Catalog
Asset catalogs simplify access to app resources by mapping between named assets and one
or more files targeted for different device attributes.
23
Image resolutions
24
Device Scale Factor
iPad Mini 1 @1x
iPhone 6s - iPhone 7 @2x
iPhone X - iPhone ** Plus @3x
UIStoryboardSegue
An object that prepares for and performs the
visual transition between two view controllers.
Explicit Intent
An Intent is a messaging object you can use to
request an action from another app component.
val intent = Intent(this,
ActivityB::class.java)
val myString = editText.text.toString()
intent.putExtra("qString", myString)
startActivity(intent)
25
UITableView
A table view displays a list of items in a single
column. UITableView is a subclass of
UIScrollView, which allows users to scroll
through the table, although UITableView allows
vertical scrolling only.
RecyclerView
26
UITableViewDataSource
It’s a protocol adopted by an object that mediates
the application’s data model for a UITableView
object. The data source provides the table-view
object with the information it needs to construct and
modify a table view.
RecyclerView.Adapter
It's an abstract class that provide a binding from
an app-specific data set to views that are
displayed within a RecyclerView.
27
func tableView(_ tableView: UITableView, cellForRowAt
indexPath: IndexPath) -> UITableViewCell {
let cell =
tableView.dequeueReusableCell(withIdentifier:
"LabelCell", for: indexPath)
cell.textLabel?.text = "Row (indexPath.row)"
return cell
}
func tableView(UITableView,
numberOfRowsInSection: Int) -> Int
fun getItemCount(): Int
fun onCreateViewHolder(parent:
ViewGroup?, viewType: Int): ViewHolder
fun onBindViewHolder(holder:
ViewHolder?, position: Int)
Cocoapods
CocoaPods is a dependency manager for Swift
and Objective-C Cocoa projects. It has over 52
thousand libraries and is used in over 3 million
apps.
Gradle
Gradle has built-in support for dependency
management and lives up the task of fulfilling
typical scenarios encountered in modern
software projects.
28
target 'MyApp' do
use_frameworks!
pod 'Alamofire', '~> 3.0'
end
pod install //generates a Podfile.lock
dependencies {
implementation fileTree(dir: 'libs',
include: ['*.jar'])
implementation
"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kot
lin_version"
implementation
"com.android.support:recyclerview-v7:28.0.0"
}
Final
considerations
29
Final considerations
● Android and iOS development worlds seem not so different!
● Don’t reject other (mobile) technologies
● Stay curious!
● To study a slightly different technology helps you to better understand your
core technology
30
THANKS
31

Weitere ähnliche Inhalte

Was ist angesagt?

EclipseCon2011 Cross-Platform Mobile Development with Eclipse
EclipseCon2011 Cross-Platform Mobile Development with EclipseEclipseCon2011 Cross-Platform Mobile Development with Eclipse
EclipseCon2011 Cross-Platform Mobile Development with Eclipse
Heiko Behrens
 
MDSD for iPhone and Android
MDSD for iPhone and AndroidMDSD for iPhone and Android
MDSD for iPhone and Android
Heiko Behrens
 
Laporan tugas mata kuliah pbo yg ke 3
Laporan tugas mata kuliah pbo yg ke 3Laporan tugas mata kuliah pbo yg ke 3
Laporan tugas mata kuliah pbo yg ke 3
Helmita putri
 

Was ist angesagt? (20)

Visual Studio.Net - Sql Server
Visual Studio.Net - Sql ServerVisual Studio.Net - Sql Server
Visual Studio.Net - Sql Server
 
beyond tellerrand: Mobile Apps with JavaScript – There's More Than Web
beyond tellerrand: Mobile Apps with JavaScript – There's More Than Webbeyond tellerrand: Mobile Apps with JavaScript – There's More Than Web
beyond tellerrand: Mobile Apps with JavaScript – There's More Than Web
 
EclipseCon2011 Cross-Platform Mobile Development with Eclipse
EclipseCon2011 Cross-Platform Mobile Development with EclipseEclipseCon2011 Cross-Platform Mobile Development with Eclipse
EclipseCon2011 Cross-Platform Mobile Development with Eclipse
 
Functional es6
Functional es6Functional es6
Functional es6
 
MDSD for iPhone and Android
MDSD for iPhone and AndroidMDSD for iPhone and Android
MDSD for iPhone and Android
 
Taming Core Data by Arek Holko, Macoscope
Taming Core Data by Arek Holko, MacoscopeTaming Core Data by Arek Holko, Macoscope
Taming Core Data by Arek Holko, Macoscope
 
Ecto DSL Introduction - Yurii Bodarev
Ecto DSL Introduction - Yurii BodarevEcto DSL Introduction - Yurii Bodarev
Ecto DSL Introduction - Yurii Bodarev
 
37c
37c37c
37c
 
Punto fijo multivariante
Punto fijo multivariantePunto fijo multivariante
Punto fijo multivariante
 
iRODS Rule Language Cheat Sheet
iRODS Rule Language Cheat SheetiRODS Rule Language Cheat Sheet
iRODS Rule Language Cheat Sheet
 
(E Book) Asp .Net Tips, Tutorials And Code
(E Book) Asp .Net Tips,  Tutorials And Code(E Book) Asp .Net Tips,  Tutorials And Code
(E Book) Asp .Net Tips, Tutorials And Code
 
Introduction to python programming 1
Introduction to python programming   1Introduction to python programming   1
Introduction to python programming 1
 
Funtional Reactive Programming with Examples in Scala + GWT
Funtional Reactive Programming with Examples in Scala + GWTFuntional Reactive Programming with Examples in Scala + GWT
Funtional Reactive Programming with Examples in Scala + GWT
 
Laporan tugas mata kuliah pbo yg ke 3
Laporan tugas mata kuliah pbo yg ke 3Laporan tugas mata kuliah pbo yg ke 3
Laporan tugas mata kuliah pbo yg ke 3
 
How to build a debug view almost for free
How to build a debug view almost for freeHow to build a debug view almost for free
How to build a debug view almost for free
 
Android App Development - 02 Activity and intent
Android App Development - 02 Activity and intentAndroid App Development - 02 Activity and intent
Android App Development - 02 Activity and intent
 
Introduction to python programming 2
Introduction to python programming   2Introduction to python programming   2
Introduction to python programming 2
 
Ejercicio sql server vs visual .net
Ejercicio sql server vs visual .netEjercicio sql server vs visual .net
Ejercicio sql server vs visual .net
 
New features in 3.0
New features in 3.0New features in 3.0
New features in 3.0
 
Python review2
Python review2Python review2
Python review2
 

Ähnlich wie How to become an Android dev starting from iOS (and vice versa)

Day 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsDay 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViews
Ahsanul Karim
 
Quick Intro to Android Development
Quick Intro to Android DevelopmentQuick Intro to Android Development
Quick Intro to Android Development
Jussi Pohjolainen
 

Ähnlich wie How to become an Android dev starting from iOS (and vice versa) (20)

What's New in Android
What's New in AndroidWhat's New in Android
What's New in Android
 
Android 3
Android 3Android 3
Android 3
 
Day 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsDay 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViews
 
Advanced Swift Generics
Advanced Swift GenericsAdvanced Swift Generics
Advanced Swift Generics
 
Android L01 - Warm Up
Android L01 - Warm UpAndroid L01 - Warm Up
Android L01 - Warm Up
 
Adopting 3D Touch in your apps
Adopting 3D Touch in your appsAdopting 3D Touch in your apps
Adopting 3D Touch in your apps
 
Reactive clean architecture
Reactive clean architectureReactive clean architecture
Reactive clean architecture
 
From Legacy to Hexagonal (An Unexpected Android Journey)
From Legacy to Hexagonal (An Unexpected Android Journey)From Legacy to Hexagonal (An Unexpected Android Journey)
From Legacy to Hexagonal (An Unexpected Android Journey)
 
Eclipse Tricks
Eclipse TricksEclipse Tricks
Eclipse Tricks
 
Android classes in mumbai
Android classes in mumbaiAndroid classes in mumbai
Android classes in mumbai
 
Building Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture ComponentsBuilding Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture Components
 
Android apps development
Android apps developmentAndroid apps development
Android apps development
 
F# And Silverlight
F# And SilverlightF# And Silverlight
F# And Silverlight
 
iOS Development (Part 2)
iOS Development (Part 2)iOS Development (Part 2)
iOS Development (Part 2)
 
K is for Kotlin
K is for KotlinK is for Kotlin
K is for Kotlin
 
Leture5 exercise onactivities
Leture5 exercise onactivitiesLeture5 exercise onactivities
Leture5 exercise onactivities
 
Lecture exercise on activities
Lecture exercise on activitiesLecture exercise on activities
Lecture exercise on activities
 
F# Presentation for SmartDevs, Hereford
F# Presentation for SmartDevs, HerefordF# Presentation for SmartDevs, Hereford
F# Presentation for SmartDevs, Hereford
 
Quick Intro to Android Development
Quick Intro to Android DevelopmentQuick Intro to Android Development
Quick Intro to Android Development
 
Creating Alloy Widgets
Creating Alloy WidgetsCreating Alloy Widgets
Creating Alloy Widgets
 

How to become an Android dev starting from iOS (and vice versa)

  • 1. 1 How to become an Android dev starting from iOS (and vice versa )
  • 3. Who are you? how many native iOS dev? 3 how many native Android dev? how mobile hybrid dev?
  • 4. What courses? Developing iOS 11 Apps with Swift Paul Hegarty https://itunes.apple.com/us/podcast/developing-i os-11-apps-with-swift/id1315130780 Developing Android apps 4
  • 8. Constants & Variables let name: String = "Giuseppe" var age: Int = 32 8 val name: String = "Giuseppe" var age: Int = 32 let name = "Giuseppe" var age = 32 val name = "Giuseppe" var age = 32 Type inference
  • 9. Classes class Person { let name: String init(name: String) { self.name = name } } let aPerson = Person(name: "Giuseppe") print(aPerson.name) 9 class Person(val name: String) val aPerson = Person("Giuseppe") print(aPerson.name)
  • 10. How to hold data struct Person { let name: String let surname: String var age: Int } let aPerson = Person(name: "Giuseppe", surname: "Filograno", age: 32) 10 data class Person(val name: String, val surname: String, var age: Int) val aPerson = Person("Giuseppe", "Filograno", 32) ● No inheritance ● Passed by value ● Default initializer No inheritance and automatically implements: ● equals()/hashCode() pair ● toString() of the form "Person(name=Giuseppe, surname=Filograno, age=32)" ● componentN() functions corresponding to the properties in their order of declaration ● copy() function
  • 11. Enums enum Suit { case spades, hearts, diamond, clubs func simpleDescription() -> String { switch self { case .spades: return "spades" case .hearts: return "hearts" case .diamond: return "diamond" case .clubs: return "clubs" } } } let hearts = Suit.hearts print(hearts.simpleDescription()) enum class Suit { spades, hearts, diamond, clubs; fun simpleDescription(): String { return when (this) { Suit.spades -> "spades" Suit.hearts -> "hearts" Suit.diamond -> "diamonds" Suit.clubs -> "clubs" } } } val hearts = Suit.hearts print(hearts.simpleDescription()) 11
  • 12. Extensions extension Array { mutating func swap(index1: Int, index2: Int) { let tmp = self[index1] self[index1] = self[index2] self[index2] = tmp } } var array = [0, 1, 2, 3] array.swap(index1: 1, index2: 2) print(array) // [0, 2, 1, 3] fun <T> MutableList<T>.swap(index1: Int, index2: Int) { val tmp = this[index1] this[index1] = this[index2] this[index2] = tmp } val mutableList = mutableListOf(0, 1, 2, 3) mutableList.swap(1, 2) print(mutableList) // [0, 2, 1, 3] 12
  • 13. Extensions extension Double { var km: Double { return self * 1_000.0 } var mm: Double { return self / 1_000.0 } var ft: Double { return self / 3.28084 } } let oneInch = 25.4.mm print("One inch is (oneInch) meters") // Prints "One inch is 0.0254 meters" let threeFeet = 3.ft print("Three feet is (threeFeet) meters") // Prints "Three feet is 0.914399970739201 meters" val Double.km get() = this * 1000.0 val Double.mm get() = this / 1_000.0 val Double.ft get() = this / 3.28084 val oneInch = 25.4.mm print("One inch is ${oneInch} meters") // Prints "One inch is 0.0254 meters" val threeFeet = 3.0.ft print("Three feet is ${threeFeet} meters") // Prints "Three feet is 0.914399970739201 meters" 13
  • 14. Optionals var aNumber: Int = 42 var optionalNumber: Int? = nil optionalNumber = 42 optionalNumber?.negate() optionalNumber!.negate() var aNumber: Int = 42 var optionalNumner: Int? = null optionalNumner = 42 val incrementedNumber = optionalNumner?.inc() val numberPlusPlus = optionalNumner!!.inc() 14
  • 15. If let var optionalNumber: Int? = nil if let number = optionalNumber { let incrementedNumber = number.advanced(by: 1) print(incrementedNumber) } optionalNumber?.let { val incrementedNumber = it.inc() print(incrementedNumber) } 15
  • 16. Lazy Stored Properties A lazy stored property is a property whose initial value is not calculated until the first time it is used. You indicate a lazy stored property by writing the lazy modifier before its declaration. class DataManager { lazy var importer = DataImporter() var data = [String]() } let manager = DataManager() manager.data.append("Some data") manager.data.append("Some more data") // the DataImporter instance for the importer property has not yet been created lazy() is a function that takes a lambda and returns an instance of Lazy<T> which can serve as a delegate for implementing a lazy property: the first call to get() executes the lambda passed to lazy() and remembers the result, subsequent calls to get() simply return the remembered result. class DataManager { val importer by lazy { DataImporter() } var data = mutableListOf<String>() } val manager = DataManager() manager.data.add("Some data") manager.data.add("Some more data") 16
  • 18. UIViewController Activity An activity provides the window in which the app draws its UI. This window typically fills the screen 18
  • 20. IBOutlet, IBAction vs ... Outlets provide a way to reference interface objects from source code files. An action (or an action method) is a piece of code that’s linked to an event that can occur in your app. 20
  • 21. … vs findViewById, listener 21
  • 23. Asset Catalog Asset catalogs simplify access to app resources by mapping between named assets and one or more files targeted for different device attributes. 23
  • 24. Image resolutions 24 Device Scale Factor iPad Mini 1 @1x iPhone 6s - iPhone 7 @2x iPhone X - iPhone ** Plus @3x
  • 25. UIStoryboardSegue An object that prepares for and performs the visual transition between two view controllers. Explicit Intent An Intent is a messaging object you can use to request an action from another app component. val intent = Intent(this, ActivityB::class.java) val myString = editText.text.toString() intent.putExtra("qString", myString) startActivity(intent) 25
  • 26. UITableView A table view displays a list of items in a single column. UITableView is a subclass of UIScrollView, which allows users to scroll through the table, although UITableView allows vertical scrolling only. RecyclerView 26
  • 27. UITableViewDataSource It’s a protocol adopted by an object that mediates the application’s data model for a UITableView object. The data source provides the table-view object with the information it needs to construct and modify a table view. RecyclerView.Adapter It's an abstract class that provide a binding from an app-specific data set to views that are displayed within a RecyclerView. 27 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "LabelCell", for: indexPath) cell.textLabel?.text = "Row (indexPath.row)" return cell } func tableView(UITableView, numberOfRowsInSection: Int) -> Int fun getItemCount(): Int fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): ViewHolder fun onBindViewHolder(holder: ViewHolder?, position: Int)
  • 28. Cocoapods CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects. It has over 52 thousand libraries and is used in over 3 million apps. Gradle Gradle has built-in support for dependency management and lives up the task of fulfilling typical scenarios encountered in modern software projects. 28 target 'MyApp' do use_frameworks! pod 'Alamofire', '~> 3.0' end pod install //generates a Podfile.lock dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kot lin_version" implementation "com.android.support:recyclerview-v7:28.0.0" }
  • 30. Final considerations ● Android and iOS development worlds seem not so different! ● Don’t reject other (mobile) technologies ● Stay curious! ● To study a slightly different technology helps you to better understand your core technology 30