SlideShare a Scribd company logo
Writing idealistic apps
by Joannis Orlandos
This presentation
» My background
» Definition of idealistic
» My recent journey
» Problems encountered
» The results
» Clean programming tips
My background
»
!
MongoKitten
»
"
Server Side Swift library developer
»
#
Vapor 3 core developers
»
$
iOS developer at FlexAppeal
MongoKitten
» MongoDB driver fully written in
Swift
» NOT a wrapper, no (Obj-)C
» Extremely performant
Vapor 3
!
» Extremely performant (async) web framework
» Huge focus on API design
» Large ecosystem
» Templating
» SQL drivers
» Protocol based dependency injection
iOS at FlexAppeal
» Employee engagement platform
» Retail, hotels and restaurants
» Striving for high quality
Idealistic
“A conception of
something in its
absolute
perfection”
“One that is
regarded as a
standard or model
of perfection or
excellence”
“An ultimate object
of endeavor; a goal”
How do I define perfection?
» Low maintenance
» Doesn't fight productivity
» Crash/bug free
» Quick startup time
The journey at Flex-Appeal
» A huge amount of experience in Swift on the Server
» Very familiar with front-end web development
» Fast learner
But...
» Overwhelming backlog
» Extremely troublesome code
» First time writing a real iOS app
» A severe lack of time and deadlines from the start
Almost unachievable
At least I can do my best
..to get close to perfection
Set up rules for my code
» Only allow interactions from parent to child
» Keep your children isolated from parents
» Responsibility must fit in a single sentence
» Keep state in one place only
» Forbid copying code at all times
» When there's code smell, always identify why
» Don't be afraid to remove code
The development process
1. Identify and layout visual hierarchy (from design)
2. Layout the view in objectively correct classes
3. Lay relations between times from parent to child
4. Identify and solve problems by abiding to the rules
I rewrote the our timeline
» Reduced code from 8066 to 3197 lines of code
» Added 3 new features
» Resolved ~10 bugs
» 1 week development time
» All newly introduced bugs were fixed in 5 minutes
Problems encountered
Due to my architecture
Problem: Relaying actions back up
class Timeline {
let cards: [TimelineCard]
}
class TimelineCard {
let header: TimelineCardHeader
...
}
class TimelineCardHeader {
// Only visible to the post's owner
let button: RemoveCardButton
}
Solution: Share a common child
class TimelineCard {
let removed: Future<Void>
let header: TimelineCardHeader
init() {
let removePromise = Promise<Void>()
header = TimelineCardHeader(onRemoval: removePromise.complete)
removed = removePromise.futureResult
}
}
Problem: Removing two cards
[
card-0 (index 0),
card-1 (index 1), // Remove this card first
card-2 (index 2),
card-3 (index 3), // Remove this card next
card-4 (index 4),
]
Result:
[
card-0 (index 0),
card-2 (index 1), // Card 2 got index 1 now, being pushed up
card-3 (index 2), // Card 3 still exists, because index 3 is removed
] // Card 4 was removed because it has index 3 now
// class Timeline
for card in cards {
card.removed.then {
// Unique (pointer) number for the instance
let cardIdentifier = ObjectIdentifier(card)
for i in 0..<cards.count {
if ObjectIdentifier(cards[i]) == cardIdentifier {
cards.remove(at: i)
return
}
}
}
}
The results
Of the journey
The obvious benefits
» Increased app stability and maintainability
» Reduced startup time by 90%
» Reduced code by 40%
» Reduced memory usage by 60%
» Closed 80% of the bugs
» Reduced development time for new features
» Created 1 big and 5 small features
The important benefits
» A lot of experience gained in iOS development
» Less stress during deployments
» Confidence and pride in your job
Programming tips
Separate code in modules
» Improved compile times
» Compile-time enforced anti-
!
» Consistent folder structure
Try to reduce state
» Switch to computed properties or reactivity
class User {
let birthDate: Date
var age: Int {
return Date().years(from: birthDate)
}
}
Less code is better
» Lower maintainance
» Less
!!!!!
Use KeyPaths
class Settings {
var shareEmail: Bool
}
class ToggleSettings {
let label: UITextView
let button: UISwitch
let settings: Settings
let keyPath: ReferenceWritableKeyPath<Settings, Bool>
init(...) { ... }
}
let button = ToggleSettings(
settings,
label: "Share email address",
atKeyPath: .shareEmail
)
Evaluate opensource projects
And learn the new concepts

More Related Content

Similar to Writing idealistic apps (Mobilization 2018)

Using F# to change the way we work
Using F# to change the way we workUsing F# to change the way we work
Using F# to change the way we work
Jon Harrop
 
Dev buchan 30 proven tips
Dev buchan 30 proven tipsDev buchan 30 proven tips
Dev buchan 30 proven tips
Bill Buchan
 
TypeScript and SharePoint Framework
TypeScript and SharePoint FrameworkTypeScript and SharePoint Framework
TypeScript and SharePoint Framework
Bob German
 
Extreme Programming Talk Wise Consulting Www.Talkwiseconsulting
Extreme  Programming    Talk Wise  Consulting   Www.TalkwiseconsultingExtreme  Programming    Talk Wise  Consulting   Www.Talkwiseconsulting
Extreme Programming Talk Wise Consulting Www.Talkwiseconsulting
talkwiseone
 
Extreme programming talk wise consulting - www.talkwiseconsulting
Extreme programming   talk wise consulting - www.talkwiseconsultingExtreme programming   talk wise consulting - www.talkwiseconsulting
Extreme programming talk wise consulting - www.talkwiseconsulting
talkwiseone
 
Intro to ColdBox MVC at Japan CFUG
Intro to ColdBox MVC at Japan CFUGIntro to ColdBox MVC at Japan CFUG
Intro to ColdBox MVC at Japan CFUG
Ortus Solutions, Corp
 
10 Reasons You MUST Consider Pattern-Aware Programming
10 Reasons You MUST Consider Pattern-Aware Programming10 Reasons You MUST Consider Pattern-Aware Programming
10 Reasons You MUST Consider Pattern-Aware Programming
PostSharp Technologies
 
CC 2015 Single Page Applications for the ASPNET Developer
CC 2015   Single Page Applications for the ASPNET DeveloperCC 2015   Single Page Applications for the ASPNET Developer
CC 2015 Single Page Applications for the ASPNET Developer
Allen Conway
 
Creating Tomorrow’s Web Applications Using Today’s Technologies
Creating Tomorrow’s Web Applications Using Today’s Technologies Creating Tomorrow’s Web Applications Using Today’s Technologies
Creating Tomorrow’s Web Applications Using Today’s Technologies
Code Mastery
 
Oracle Endeca 101 Developer Introduction High Level Overview
Oracle Endeca 101 Developer Introduction High Level OverviewOracle Endeca 101 Developer Introduction High Level Overview
Oracle Endeca 101 Developer Introduction High Level Overview
Gordon Kiser
 
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
Fwdays
 
Old code doesn't stink
Old code doesn't stinkOld code doesn't stink
Old code doesn't stink
Martin Gutenbrunner
 
Silicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your databaseSilicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your database
Speedment, Inc.
 
How to generate customized java 8 code from your database
How to generate customized java 8 code from your databaseHow to generate customized java 8 code from your database
How to generate customized java 8 code from your database
Speedment, Inc.
 
Clean Code II - Dependency Injection
Clean Code II - Dependency InjectionClean Code II - Dependency Injection
Clean Code II - Dependency Injection
Theo Jungeblut
 
Clean code, Feb 2012
Clean code, Feb 2012Clean code, Feb 2012
Clean code, Feb 2012
cobyst
 
Untying the Knots of Web Dev with Internet Explorer
Untying the Knots of Web Dev with Internet Explorer Untying the Knots of Web Dev with Internet Explorer
Untying the Knots of Web Dev with Internet Explorer
Sarah Dutkiewicz
 
Agileand saas davepatterson_armandofox_050813webinar
Agileand saas davepatterson_armandofox_050813webinarAgileand saas davepatterson_armandofox_050813webinar
Agileand saas davepatterson_armandofox_050813webinar
Roberto Jr. Figueroa
 
Need 4 Speed FI
Need 4 Speed FINeed 4 Speed FI
Need 4 Speed FI
Marcel Bruch
 
Microsoft ASP.NET 5 - The new kid on the block
Microsoft ASP.NET 5 - The new kid on the block Microsoft ASP.NET 5 - The new kid on the block
Microsoft ASP.NET 5 - The new kid on the block
Christos Matskas
 

Similar to Writing idealistic apps (Mobilization 2018) (20)

Using F# to change the way we work
Using F# to change the way we workUsing F# to change the way we work
Using F# to change the way we work
 
Dev buchan 30 proven tips
Dev buchan 30 proven tipsDev buchan 30 proven tips
Dev buchan 30 proven tips
 
TypeScript and SharePoint Framework
TypeScript and SharePoint FrameworkTypeScript and SharePoint Framework
TypeScript and SharePoint Framework
 
Extreme Programming Talk Wise Consulting Www.Talkwiseconsulting
Extreme  Programming    Talk Wise  Consulting   Www.TalkwiseconsultingExtreme  Programming    Talk Wise  Consulting   Www.Talkwiseconsulting
Extreme Programming Talk Wise Consulting Www.Talkwiseconsulting
 
Extreme programming talk wise consulting - www.talkwiseconsulting
Extreme programming   talk wise consulting - www.talkwiseconsultingExtreme programming   talk wise consulting - www.talkwiseconsulting
Extreme programming talk wise consulting - www.talkwiseconsulting
 
Intro to ColdBox MVC at Japan CFUG
Intro to ColdBox MVC at Japan CFUGIntro to ColdBox MVC at Japan CFUG
Intro to ColdBox MVC at Japan CFUG
 
10 Reasons You MUST Consider Pattern-Aware Programming
10 Reasons You MUST Consider Pattern-Aware Programming10 Reasons You MUST Consider Pattern-Aware Programming
10 Reasons You MUST Consider Pattern-Aware Programming
 
CC 2015 Single Page Applications for the ASPNET Developer
CC 2015   Single Page Applications for the ASPNET DeveloperCC 2015   Single Page Applications for the ASPNET Developer
CC 2015 Single Page Applications for the ASPNET Developer
 
Creating Tomorrow’s Web Applications Using Today’s Technologies
Creating Tomorrow’s Web Applications Using Today’s Technologies Creating Tomorrow’s Web Applications Using Today’s Technologies
Creating Tomorrow’s Web Applications Using Today’s Technologies
 
Oracle Endeca 101 Developer Introduction High Level Overview
Oracle Endeca 101 Developer Introduction High Level OverviewOracle Endeca 101 Developer Introduction High Level Overview
Oracle Endeca 101 Developer Introduction High Level Overview
 
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
 
Old code doesn't stink
Old code doesn't stinkOld code doesn't stink
Old code doesn't stink
 
Silicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your databaseSilicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your database
 
How to generate customized java 8 code from your database
How to generate customized java 8 code from your databaseHow to generate customized java 8 code from your database
How to generate customized java 8 code from your database
 
Clean Code II - Dependency Injection
Clean Code II - Dependency InjectionClean Code II - Dependency Injection
Clean Code II - Dependency Injection
 
Clean code, Feb 2012
Clean code, Feb 2012Clean code, Feb 2012
Clean code, Feb 2012
 
Untying the Knots of Web Dev with Internet Explorer
Untying the Knots of Web Dev with Internet Explorer Untying the Knots of Web Dev with Internet Explorer
Untying the Knots of Web Dev with Internet Explorer
 
Agileand saas davepatterson_armandofox_050813webinar
Agileand saas davepatterson_armandofox_050813webinarAgileand saas davepatterson_armandofox_050813webinar
Agileand saas davepatterson_armandofox_050813webinar
 
Need 4 Speed FI
Need 4 Speed FINeed 4 Speed FI
Need 4 Speed FI
 
Microsoft ASP.NET 5 - The new kid on the block
Microsoft ASP.NET 5 - The new kid on the block Microsoft ASP.NET 5 - The new kid on the block
Microsoft ASP.NET 5 - The new kid on the block
 

Recently uploaded

Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
Pablo Gómez Abajo
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
Jason Yip
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
saastr
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
AstuteBusiness
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
DianaGray10
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
operationspcvita
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
DianaGray10
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
Javier Junquera
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
Edge AI and Vision Alliance
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframeDigital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Precisely
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Alpen-Adria-Universität
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 

Recently uploaded (20)

Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframeDigital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 

Writing idealistic apps (Mobilization 2018)

  • 1. Writing idealistic apps by Joannis Orlandos
  • 2. This presentation » My background » Definition of idealistic » My recent journey » Problems encountered » The results » Clean programming tips
  • 3. My background » ! MongoKitten » " Server Side Swift library developer » # Vapor 3 core developers » $ iOS developer at FlexAppeal
  • 4. MongoKitten » MongoDB driver fully written in Swift » NOT a wrapper, no (Obj-)C » Extremely performant
  • 5. Vapor 3 ! » Extremely performant (async) web framework » Huge focus on API design » Large ecosystem » Templating » SQL drivers » Protocol based dependency injection
  • 6. iOS at FlexAppeal » Employee engagement platform » Retail, hotels and restaurants » Striving for high quality
  • 8. “A conception of something in its absolute perfection”
  • 9. “One that is regarded as a standard or model of perfection or excellence”
  • 10. “An ultimate object of endeavor; a goal”
  • 11. How do I define perfection? » Low maintenance » Doesn't fight productivity » Crash/bug free » Quick startup time
  • 12. The journey at Flex-Appeal
  • 13. » A huge amount of experience in Swift on the Server » Very familiar with front-end web development » Fast learner But... » Overwhelming backlog » Extremely troublesome code » First time writing a real iOS app » A severe lack of time and deadlines from the start
  • 15. At least I can do my best ..to get close to perfection
  • 16. Set up rules for my code » Only allow interactions from parent to child » Keep your children isolated from parents » Responsibility must fit in a single sentence » Keep state in one place only » Forbid copying code at all times » When there's code smell, always identify why » Don't be afraid to remove code
  • 17. The development process 1. Identify and layout visual hierarchy (from design) 2. Layout the view in objectively correct classes 3. Lay relations between times from parent to child 4. Identify and solve problems by abiding to the rules
  • 18. I rewrote the our timeline » Reduced code from 8066 to 3197 lines of code » Added 3 new features » Resolved ~10 bugs » 1 week development time » All newly introduced bugs were fixed in 5 minutes
  • 19. Problems encountered Due to my architecture
  • 20. Problem: Relaying actions back up class Timeline { let cards: [TimelineCard] } class TimelineCard { let header: TimelineCardHeader ... } class TimelineCardHeader { // Only visible to the post's owner let button: RemoveCardButton }
  • 21. Solution: Share a common child class TimelineCard { let removed: Future<Void> let header: TimelineCardHeader init() { let removePromise = Promise<Void>() header = TimelineCardHeader(onRemoval: removePromise.complete) removed = removePromise.futureResult } }
  • 22. Problem: Removing two cards [ card-0 (index 0), card-1 (index 1), // Remove this card first card-2 (index 2), card-3 (index 3), // Remove this card next card-4 (index 4), ] Result: [ card-0 (index 0), card-2 (index 1), // Card 2 got index 1 now, being pushed up card-3 (index 2), // Card 3 still exists, because index 3 is removed ] // Card 4 was removed because it has index 3 now
  • 23. // class Timeline for card in cards { card.removed.then { // Unique (pointer) number for the instance let cardIdentifier = ObjectIdentifier(card) for i in 0..<cards.count { if ObjectIdentifier(cards[i]) == cardIdentifier { cards.remove(at: i) return } } } }
  • 25. The obvious benefits » Increased app stability and maintainability » Reduced startup time by 90% » Reduced code by 40% » Reduced memory usage by 60% » Closed 80% of the bugs » Reduced development time for new features » Created 1 big and 5 small features
  • 26. The important benefits » A lot of experience gained in iOS development » Less stress during deployments » Confidence and pride in your job
  • 28. Separate code in modules » Improved compile times » Compile-time enforced anti- ! » Consistent folder structure
  • 29. Try to reduce state » Switch to computed properties or reactivity class User { let birthDate: Date var age: Int { return Date().years(from: birthDate) } }
  • 30. Less code is better » Lower maintainance » Less !!!!!
  • 31. Use KeyPaths class Settings { var shareEmail: Bool } class ToggleSettings { let label: UITextView let button: UISwitch let settings: Settings let keyPath: ReferenceWritableKeyPath<Settings, Bool> init(...) { ... } } let button = ToggleSettings( settings, label: "Share email address", atKeyPath: .shareEmail )
  • 32. Evaluate opensource projects And learn the new concepts