SlideShare a Scribd company logo
Be armed to the teeth
to maintain a high quality iOS code
Anastasia Kazakova
Program vs Product
• ACM-ICPC: Solve quicker than others, pass tests, start another task.
• Real word: How often do you rewrite the project from scratch?
What is code quality?
Some say:
Easy to understand
Easy to maintain
Easy to use
Works right
Some say:
high quality == meets
requirements
Some say (CISQ):
Reliability
Efficiency
Security
Maintainability
Size
What is code quality?
WTFs/minute metric
Have you ever encountered this?
… or this …
…or this?
GOTO FAIL?
Possible problems
• Dead code
• Copy/paste,
duplicated code
• Hiding scope
• Too much happening
at one place
• Code style
inconsistency
• Patterns violations
• Bad coding practices
• Over-generalized code
• …
What do we have to do?
1. Follow the code style
2. Generate code
3. Run static analysis
4. Refactor
5. Run unit tests
"We need tools”
Bjarne Stroustrup at CppCon2015
Armed to the teeth #1:
Code style
• Apple’s coding guidelines for Cocoa
• raywenderlich.com:
• https://github.com/raywenderlich/objective-c-style-guide
• https://github.com/raywenderlich/swift-style-guide
• GitHub:
• https://github.com/github/objective-c-style-guide
• https://github.com/github/swift-style-guide
• Spotify
• https://github.com/spotify/ios-style
Armed to the teeth #1:
Code style
Clang-Format:
• Stand-alone, tools integration.
• Plugin for Xcode: https://github.com/travisjeffery/ClangFormat-
Xcode with option to enable format on save.
• Indents, braces, breaks, line length, base styles, aligns, and much
more.
• Objective-C, no Swift :(
Armed to the teeth #1:
Code style
Clang-Format
Armed to the teeth #1:
Code style
• Pre-commit hooks: ocstyle, SwiftFormat, SpaceCommander (uses
Clang-Format) & more on GitHub.
• Some check in SwiftLint
Armed to the teeth #1:
Code style
AppCode
• Settings for
Objective-C, C, C+
+, Swift.
• Reformat action
• On-the-fly
• Format on commit
stage
Armed to the teeth #2:
Generate code
• Xcode pre-generates some methods when creating files/classes.
• Xcode code snippets for Objective-C and Swift.
• Override/Implement code generation on completion in Xcode.
• There were some 3d-party tools like xobjc on GitHub.
Armed to the teeth #2:
Generate code
AppCode:
• Generate menu
• Live Templates
• Create from usage
• Override/Implement
• File Templates
Armed to the teeth #3:
Static analysis
Tools:
• Guidelines/rules
• Configuration settings
• On-the-fly mode
• Quick fixes
Armed to the teeth #3:
Static analysis
Clang analyzer:
• Open source, part of Clang project
• Integrated into Xcode
• Basic checks, dead code, API checks, language specific checks
But don’t forget to switch them all on!
Armed to the teeth #3:
Static analysis
OCLint: https://github.com/oclint
• Metric-based defects:
• complicated code;
• redundant code;
• long methods, long parameters lists, etc.;
• bad practices (like parameter reassignment).
• 58 rules that can be customized per project
• Integrated with clang analyzer
• Can be used inside the Xcode
Armed to the teeth #3:
Static analysis
SwiftLint: https://github.com/realm/SwiftLint
• Similar to OCLint
• Limited in number of rules, planned rules:
• Code style checks (spaces, newlines);
• let over var rule; struct over classes;
• Working with optionals (like not forcing unwrapping);
• Specify access control and more.
• Contribute!
Armed to the teeth #3:
Static analysis
OCLint and SwiftLint
Armed to the teeth #3:
Static analysis
OCLint and SwiftLint
Armed to the teeth #3:
Static analysis
AppCode
• Integrated with clang
analyzer
• 60 inspections for
Objective-C, 40 for C/
C++, on-the-fly mode
• Settings, severity level,
profiles
Armed to the teeth #3:
Static analysis
AppCode: complicated cases, bulk mode
Armed to the teeth #3:
Static analysis
AppCode: quick fixes, DFA
Armed to the teeth #3:
Static analysis
AppCode:
Checks on commit
stage
• formatter
• code analysis
• TODO
• imports
Armed to the teeth #4:
Refactoring
• Xcode refactorings
• Rename, Extract (method/function), Move up/down, Create superclass, Encapsulate,
Convert…
• C and Objective-C only
• AppCode refactorings
• + Inline, Safe delete, Change signature, Extract everything, Rename with non-code
usages (strings, comment, xib, etc.) for Objective-C, C, C++
• Rename in Swift
• Some projects on GitHub, like Refactorial
Armed to the teeth #5:
Unit testing
• XCTest
• Kiwi: BDD framework for Objective-C
• Google Test: tests for C/C++
• Specta/Expecta: TDD / BDD framework for Objective-C
• Quick/Nimble: Swift BDD framework
Armed to the teeth #5:
Unit testing
AppCode: unit tests code generation
Summary
TODO:
• Follow selected code style
• Generate standard pieces of code
• Use the swiss-army knife thoughtfully
to find smells
• Refactor to clean up the smells
• Cover every inch with the unit tests
Tools:
• Xcode
• Clang-Format
• OC/Swift-Lint
• AppCode
Thanks for listening!
Anastasia.Kazakova@jetbrains.com
@anastasiak2512
IDE for iOS/OS X dev: http://jetbrains.com/appcode, @appcode

More Related Content

What's hot

Debugging C# Applications
Debugging C# ApplicationsDebugging C# Applications
Debugging C# Applications
Jaliya Udagedara
 
Java Code Quality Tools
Java Code Quality ToolsJava Code Quality Tools
Java Code Quality ToolsOrest Ivasiv
 
Code review process with JetBrains UpSource
Code review process with JetBrains UpSourceCode review process with JetBrains UpSource
Code review process with JetBrains UpSource
Oleksii Prohonnyi
 
Clean Code III - Software Craftsmanship
Clean Code III - Software CraftsmanshipClean Code III - Software Craftsmanship
Clean Code III - Software Craftsmanship
Theo Jungeblut
 
Effective code reviews
Effective code reviewsEffective code reviews
Effective code reviews
Sebastian Marek
 
Code Review: How and When
Code Review: How and WhenCode Review: How and When
Code Review: How and When
Paul Gower
 
Code Review
Code ReviewCode Review
Code Review
Tu Hoang
 
Code Review for iOS
Code Review for iOSCode Review for iOS
Code Review for iOS
KLabCyscorpions-TechBlog
 
Concepts of Functional Programming for Java Brains (2010)
Concepts of Functional Programming for Java Brains (2010)Concepts of Functional Programming for Java Brains (2010)
Concepts of Functional Programming for Java Brains (2010)Peter Kofler
 
Static code analysis
Static code analysisStatic code analysis
Static code analysisRune Sundling
 
Code Review: How and When
Code Review: How and WhenCode Review: How and When
Code Review: How and When
Paul Gower
 
Code Review Tool Evaluation
Code Review Tool EvaluationCode Review Tool Evaluation
Code Review Tool Evaluation
Kate Semizhon
 
Real life unit testing tools and practices
Real life unit testing   tools and practicesReal life unit testing   tools and practices
Real life unit testing tools and practicesGil Zilberfeld
 
Continuous code quality_in_java
Continuous code quality_in_javaContinuous code quality_in_java
Continuous code quality_in_java
Manimekalai48
 
Top 10 static code analysis tool
Top 10 static code analysis toolTop 10 static code analysis tool
Top 10 static code analysis tool
scmGalaxy Inc
 
Robot Framework : Lord of the Rings By Asheesh M
Robot Framework : Lord of the Rings By Asheesh MRobot Framework : Lord of the Rings By Asheesh M
Robot Framework : Lord of the Rings By Asheesh M
Agile Testing Alliance
 
Coding Standard And Code Review
Coding Standard And Code ReviewCoding Standard And Code Review
Coding Standard And Code Review
Milan Vukoje
 
Functional Tests Automation with Robot Framework
Functional Tests Automation with Robot FrameworkFunctional Tests Automation with Robot Framework
Functional Tests Automation with Robot Framework
laurent bristiel
 
Real Developers Don't Need Unit Tests
Real Developers Don't Need Unit TestsReal Developers Don't Need Unit Tests
Real Developers Don't Need Unit Tests
John Ferguson Smart Limited
 

What's hot (20)

Debugging C# Applications
Debugging C# ApplicationsDebugging C# Applications
Debugging C# Applications
 
Java Code Quality Tools
Java Code Quality ToolsJava Code Quality Tools
Java Code Quality Tools
 
Code review process with JetBrains UpSource
Code review process with JetBrains UpSourceCode review process with JetBrains UpSource
Code review process with JetBrains UpSource
 
Clean Code III - Software Craftsmanship
Clean Code III - Software CraftsmanshipClean Code III - Software Craftsmanship
Clean Code III - Software Craftsmanship
 
Effective code reviews
Effective code reviewsEffective code reviews
Effective code reviews
 
Code Review: How and When
Code Review: How and WhenCode Review: How and When
Code Review: How and When
 
Code Review
Code ReviewCode Review
Code Review
 
Java Code Quality Tools
Java Code Quality ToolsJava Code Quality Tools
Java Code Quality Tools
 
Code Review for iOS
Code Review for iOSCode Review for iOS
Code Review for iOS
 
Concepts of Functional Programming for Java Brains (2010)
Concepts of Functional Programming for Java Brains (2010)Concepts of Functional Programming for Java Brains (2010)
Concepts of Functional Programming for Java Brains (2010)
 
Static code analysis
Static code analysisStatic code analysis
Static code analysis
 
Code Review: How and When
Code Review: How and WhenCode Review: How and When
Code Review: How and When
 
Code Review Tool Evaluation
Code Review Tool EvaluationCode Review Tool Evaluation
Code Review Tool Evaluation
 
Real life unit testing tools and practices
Real life unit testing   tools and practicesReal life unit testing   tools and practices
Real life unit testing tools and practices
 
Continuous code quality_in_java
Continuous code quality_in_javaContinuous code quality_in_java
Continuous code quality_in_java
 
Top 10 static code analysis tool
Top 10 static code analysis toolTop 10 static code analysis tool
Top 10 static code analysis tool
 
Robot Framework : Lord of the Rings By Asheesh M
Robot Framework : Lord of the Rings By Asheesh MRobot Framework : Lord of the Rings By Asheesh M
Robot Framework : Lord of the Rings By Asheesh M
 
Coding Standard And Code Review
Coding Standard And Code ReviewCoding Standard And Code Review
Coding Standard And Code Review
 
Functional Tests Automation with Robot Framework
Functional Tests Automation with Robot FrameworkFunctional Tests Automation with Robot Framework
Functional Tests Automation with Robot Framework
 
Real Developers Don't Need Unit Tests
Real Developers Don't Need Unit TestsReal Developers Don't Need Unit Tests
Real Developers Don't Need Unit Tests
 

Viewers also liked

Advice on academic writing
Advice on academic writingAdvice on academic writing
Advice on academic writing
Barbara Rodriguez
 
Tarea módulo 4
Tarea módulo 4Tarea módulo 4
Tarea módulo 4
Adrián Obando Rodríguez
 
Psicología tema 2 trabajo y evaluación
Psicología tema 2 trabajo y evaluaciónPsicología tema 2 trabajo y evaluación
Psicología tema 2 trabajo y evaluación
doourense
 
Lisans Diploması
Lisans DiplomasıLisans Diploması
Lisans DiplomasıSalih Guner
 
Off the rails
Off the railsOff the rails
Off the rails
101k_
 
Revisão: Absolutismo e Reforma Religiosas
Revisão: Absolutismo e Reforma ReligiosasRevisão: Absolutismo e Reforma Religiosas
Revisão: Absolutismo e Reforma Religiosas
ValderiVini
 
Harnessing Social and Mobile to Court the Digital Consumer
Harnessing Social and Mobile to Court the Digital ConsumerHarnessing Social and Mobile to Court the Digital Consumer
Harnessing Social and Mobile to Court the Digital Consumer
Cognizant
 
Advice on academic writing
Advice on academic writingAdvice on academic writing
Advice on academic writing
Mariana Affre
 
Kidnap and ransom insurance at an inflection point
Kidnap and ransom insurance at an inflection pointKidnap and ransom insurance at an inflection point
Kidnap and ransom insurance at an inflection point
Cognizant
 
FORUM SAILING CUP 2016
FORUM SAILING CUP 2016FORUM SAILING CUP 2016
FORUM SAILING CUP 2016
Comunicazione Italiana srl
 
Scleromarketing | BTO 2016 | Tiziana Tirelli
Scleromarketing | BTO 2016 | Tiziana TirelliScleromarketing | BTO 2016 | Tiziana Tirelli
Scleromarketing | BTO 2016 | Tiziana Tirelli
BTO Educational
 
Proposal kejurda bjb cup
Proposal kejurda bjb cup Proposal kejurda bjb cup
Proposal kejurda bjb cup
OPTISIMUS
 
Trabalho sobre a família
Trabalho sobre a famíliaTrabalho sobre a família
Trabalho sobre a família
CriatividadeTechno
 
TRADE_DETERGENTI_AUTO_Lancellotti_Invernizzi
TRADE_DETERGENTI_AUTO_Lancellotti_InvernizziTRADE_DETERGENTI_AUTO_Lancellotti_Invernizzi
TRADE_DETERGENTI_AUTO_Lancellotti_InvernizziRoberto Lancellotti
 
Embedded Software Quality
Embedded Software QualityEmbedded Software Quality
Embedded Software Quality
InfinIT - Innovationsnetværket for it
 
Al di là del muro
Al di là del muroAl di là del muro
Al di là del muro
Savina Gravante
 
Diktat Panduan Matlab
Diktat Panduan MatlabDiktat Panduan Matlab
Diktat Panduan Matlab
Simon Patabang
 
Vaccination of healthcare workers, Dr. V. Anil Kumar
Vaccination of healthcare workers, Dr. V. Anil KumarVaccination of healthcare workers, Dr. V. Anil Kumar
Vaccination of healthcare workers, Dr. V. Anil Kumar
ohscmcvellore
 

Viewers also liked (18)

Advice on academic writing
Advice on academic writingAdvice on academic writing
Advice on academic writing
 
Tarea módulo 4
Tarea módulo 4Tarea módulo 4
Tarea módulo 4
 
Psicología tema 2 trabajo y evaluación
Psicología tema 2 trabajo y evaluaciónPsicología tema 2 trabajo y evaluación
Psicología tema 2 trabajo y evaluación
 
Lisans Diploması
Lisans DiplomasıLisans Diploması
Lisans Diploması
 
Off the rails
Off the railsOff the rails
Off the rails
 
Revisão: Absolutismo e Reforma Religiosas
Revisão: Absolutismo e Reforma ReligiosasRevisão: Absolutismo e Reforma Religiosas
Revisão: Absolutismo e Reforma Religiosas
 
Harnessing Social and Mobile to Court the Digital Consumer
Harnessing Social and Mobile to Court the Digital ConsumerHarnessing Social and Mobile to Court the Digital Consumer
Harnessing Social and Mobile to Court the Digital Consumer
 
Advice on academic writing
Advice on academic writingAdvice on academic writing
Advice on academic writing
 
Kidnap and ransom insurance at an inflection point
Kidnap and ransom insurance at an inflection pointKidnap and ransom insurance at an inflection point
Kidnap and ransom insurance at an inflection point
 
FORUM SAILING CUP 2016
FORUM SAILING CUP 2016FORUM SAILING CUP 2016
FORUM SAILING CUP 2016
 
Scleromarketing | BTO 2016 | Tiziana Tirelli
Scleromarketing | BTO 2016 | Tiziana TirelliScleromarketing | BTO 2016 | Tiziana Tirelli
Scleromarketing | BTO 2016 | Tiziana Tirelli
 
Proposal kejurda bjb cup
Proposal kejurda bjb cup Proposal kejurda bjb cup
Proposal kejurda bjb cup
 
Trabalho sobre a família
Trabalho sobre a famíliaTrabalho sobre a família
Trabalho sobre a família
 
TRADE_DETERGENTI_AUTO_Lancellotti_Invernizzi
TRADE_DETERGENTI_AUTO_Lancellotti_InvernizziTRADE_DETERGENTI_AUTO_Lancellotti_Invernizzi
TRADE_DETERGENTI_AUTO_Lancellotti_Invernizzi
 
Embedded Software Quality
Embedded Software QualityEmbedded Software Quality
Embedded Software Quality
 
Al di là del muro
Al di là del muroAl di là del muro
Al di là del muro
 
Diktat Panduan Matlab
Diktat Panduan MatlabDiktat Panduan Matlab
Diktat Panduan Matlab
 
Vaccination of healthcare workers, Dr. V. Anil Kumar
Vaccination of healthcare workers, Dr. V. Anil KumarVaccination of healthcare workers, Dr. V. Anil Kumar
Vaccination of healthcare workers, Dr. V. Anil Kumar
 

Similar to Be armed to the teeth to maintain a high quality iOS code

Swift should I switch?
Swift should I switch?Swift should I switch?
Swift should I switch?
wulfgeng
 
Facilitating Idiomatic Swift with Objective-C
Facilitating Idiomatic Swift with Objective-CFacilitating Idiomatic Swift with Objective-C
Facilitating Idiomatic Swift with Objective-C
Aaron Taylor
 
2R-3KS03-OOP_UNIT-I (Part-A)_2023-24.pptx
2R-3KS03-OOP_UNIT-I (Part-A)_2023-24.pptx2R-3KS03-OOP_UNIT-I (Part-A)_2023-24.pptx
2R-3KS03-OOP_UNIT-I (Part-A)_2023-24.pptx
GauravGamer2
 
Static-Analysis-in-Industry.pptx
Static-Analysis-in-Industry.pptxStatic-Analysis-in-Industry.pptx
Static-Analysis-in-Industry.pptx
ShivashankarHR1
 
Xcode, Basics and Beyond
Xcode, Basics and BeyondXcode, Basics and Beyond
Xcode, Basics and Beyondrsebbe
 
The iOS technical interview: get your dream job as an iOS developer
The iOS technical interview: get your dream job as an iOS developerThe iOS technical interview: get your dream job as an iOS developer
The iOS technical interview: get your dream job as an iOS developer
Juan C Catalan
 
NetWork - 15.10.2011 - Applied code generation in .NET
NetWork - 15.10.2011 - Applied code generation in .NET NetWork - 15.10.2011 - Applied code generation in .NET
NetWork - 15.10.2011 - Applied code generation in .NET Dmytro Mindra
 
Letter to a Junior Developer: The Engineering Side of Programming
Letter to a Junior Developer: The Engineering Side of ProgrammingLetter to a Junior Developer: The Engineering Side of Programming
Letter to a Junior Developer: The Engineering Side of Programming
Lazar Kovacevic
 
Philly CocoaHeads 20160414 - Building Your App SDK With Swift
Philly CocoaHeads 20160414 - Building Your App SDK With SwiftPhilly CocoaHeads 20160414 - Building Your App SDK With Swift
Philly CocoaHeads 20160414 - Building Your App SDK With Swift
Jordan Yaker
 
iOS Development Gems in AppCode
iOS Development Gems in AppCodeiOS Development Gems in AppCode
iOS Development Gems in AppCode
Alexey Ushakov
 
«iOS Development Gems in AppCode» — Алексей Ушаков, JetBrains
«iOS Development Gems in AppCode» — Алексей Ушаков, JetBrains«iOS Development Gems in AppCode» — Алексей Ушаков, JetBrains
«iOS Development Gems in AppCode» — Алексей Ушаков, JetBrains
e-Legion
 
How to write good quality code
How to write good quality codeHow to write good quality code
How to write good quality code
Hayden Bleasel
 
The Big Easy: Native Mobile App Development with Appcelerator Titanium and Ja...
The Big Easy: Native Mobile App Development with Appcelerator Titanium and Ja...The Big Easy: Native Mobile App Development with Appcelerator Titanium and Ja...
The Big Easy: Native Mobile App Development with Appcelerator Titanium and Ja...
Adam Paxton
 
Clean Code Part III - Craftsmanship at SoCal Code Camp
Clean Code Part III - Craftsmanship at SoCal Code CampClean Code Part III - Craftsmanship at SoCal Code Camp
Clean Code Part III - Craftsmanship at SoCal Code Camp
Theo Jungeblut
 
How To Use Selenium Successfully
How To Use Selenium SuccessfullyHow To Use Selenium Successfully
How To Use Selenium Successfully
Dave Haeffner
 
Infinum Android Talks #13 - Developing Android Apps Like Navy Seals by Ivan Kušt
Infinum Android Talks #13 - Developing Android Apps Like Navy Seals by Ivan KuštInfinum Android Talks #13 - Developing Android Apps Like Navy Seals by Ivan Kušt
Infinum Android Talks #13 - Developing Android Apps Like Navy Seals by Ivan Kušt
Infinum
 
Developer Job in Practice
Developer Job in PracticeDeveloper Job in Practice
Developer Job in Practice
intive
 
Bootstrapping iPhone Development
Bootstrapping iPhone DevelopmentBootstrapping iPhone Development
Bootstrapping iPhone Development
ThoughtWorks
 
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
 
Xamarin v.Now
Xamarin v.NowXamarin v.Now
Xamarin v.Now
Craig Dunn
 

Similar to Be armed to the teeth to maintain a high quality iOS code (20)

Swift should I switch?
Swift should I switch?Swift should I switch?
Swift should I switch?
 
Facilitating Idiomatic Swift with Objective-C
Facilitating Idiomatic Swift with Objective-CFacilitating Idiomatic Swift with Objective-C
Facilitating Idiomatic Swift with Objective-C
 
2R-3KS03-OOP_UNIT-I (Part-A)_2023-24.pptx
2R-3KS03-OOP_UNIT-I (Part-A)_2023-24.pptx2R-3KS03-OOP_UNIT-I (Part-A)_2023-24.pptx
2R-3KS03-OOP_UNIT-I (Part-A)_2023-24.pptx
 
Static-Analysis-in-Industry.pptx
Static-Analysis-in-Industry.pptxStatic-Analysis-in-Industry.pptx
Static-Analysis-in-Industry.pptx
 
Xcode, Basics and Beyond
Xcode, Basics and BeyondXcode, Basics and Beyond
Xcode, Basics and Beyond
 
The iOS technical interview: get your dream job as an iOS developer
The iOS technical interview: get your dream job as an iOS developerThe iOS technical interview: get your dream job as an iOS developer
The iOS technical interview: get your dream job as an iOS developer
 
NetWork - 15.10.2011 - Applied code generation in .NET
NetWork - 15.10.2011 - Applied code generation in .NET NetWork - 15.10.2011 - Applied code generation in .NET
NetWork - 15.10.2011 - Applied code generation in .NET
 
Letter to a Junior Developer: The Engineering Side of Programming
Letter to a Junior Developer: The Engineering Side of ProgrammingLetter to a Junior Developer: The Engineering Side of Programming
Letter to a Junior Developer: The Engineering Side of Programming
 
Philly CocoaHeads 20160414 - Building Your App SDK With Swift
Philly CocoaHeads 20160414 - Building Your App SDK With SwiftPhilly CocoaHeads 20160414 - Building Your App SDK With Swift
Philly CocoaHeads 20160414 - Building Your App SDK With Swift
 
iOS Development Gems in AppCode
iOS Development Gems in AppCodeiOS Development Gems in AppCode
iOS Development Gems in AppCode
 
«iOS Development Gems in AppCode» — Алексей Ушаков, JetBrains
«iOS Development Gems in AppCode» — Алексей Ушаков, JetBrains«iOS Development Gems in AppCode» — Алексей Ушаков, JetBrains
«iOS Development Gems in AppCode» — Алексей Ушаков, JetBrains
 
How to write good quality code
How to write good quality codeHow to write good quality code
How to write good quality code
 
The Big Easy: Native Mobile App Development with Appcelerator Titanium and Ja...
The Big Easy: Native Mobile App Development with Appcelerator Titanium and Ja...The Big Easy: Native Mobile App Development with Appcelerator Titanium and Ja...
The Big Easy: Native Mobile App Development with Appcelerator Titanium and Ja...
 
Clean Code Part III - Craftsmanship at SoCal Code Camp
Clean Code Part III - Craftsmanship at SoCal Code CampClean Code Part III - Craftsmanship at SoCal Code Camp
Clean Code Part III - Craftsmanship at SoCal Code Camp
 
How To Use Selenium Successfully
How To Use Selenium SuccessfullyHow To Use Selenium Successfully
How To Use Selenium Successfully
 
Infinum Android Talks #13 - Developing Android Apps Like Navy Seals by Ivan Kušt
Infinum Android Talks #13 - Developing Android Apps Like Navy Seals by Ivan KuštInfinum Android Talks #13 - Developing Android Apps Like Navy Seals by Ivan Kušt
Infinum Android Talks #13 - Developing Android Apps Like Navy Seals by Ivan Kušt
 
Developer Job in Practice
Developer Job in PracticeDeveloper Job in Practice
Developer Job in Practice
 
Bootstrapping iPhone Development
Bootstrapping iPhone DevelopmentBootstrapping iPhone Development
Bootstrapping iPhone Development
 
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
 
Xamarin v.Now
Xamarin v.NowXamarin v.Now
Xamarin v.Now
 

Recently uploaded

Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 

Recently uploaded (20)

Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 

Be armed to the teeth to maintain a high quality iOS code

  • 1. Be armed to the teeth to maintain a high quality iOS code Anastasia Kazakova
  • 2. Program vs Product • ACM-ICPC: Solve quicker than others, pass tests, start another task. • Real word: How often do you rewrite the project from scratch?
  • 3. What is code quality? Some say: Easy to understand Easy to maintain Easy to use Works right Some say: high quality == meets requirements Some say (CISQ): Reliability Efficiency Security Maintainability Size
  • 4. What is code quality?
  • 6. Have you ever encountered this?
  • 10. Possible problems • Dead code • Copy/paste, duplicated code • Hiding scope • Too much happening at one place • Code style inconsistency • Patterns violations • Bad coding practices • Over-generalized code • …
  • 11. What do we have to do? 1. Follow the code style 2. Generate code 3. Run static analysis 4. Refactor 5. Run unit tests
  • 12. "We need tools” Bjarne Stroustrup at CppCon2015
  • 13. Armed to the teeth #1: Code style • Apple’s coding guidelines for Cocoa • raywenderlich.com: • https://github.com/raywenderlich/objective-c-style-guide • https://github.com/raywenderlich/swift-style-guide • GitHub: • https://github.com/github/objective-c-style-guide • https://github.com/github/swift-style-guide • Spotify • https://github.com/spotify/ios-style
  • 14. Armed to the teeth #1: Code style Clang-Format: • Stand-alone, tools integration. • Plugin for Xcode: https://github.com/travisjeffery/ClangFormat- Xcode with option to enable format on save. • Indents, braces, breaks, line length, base styles, aligns, and much more. • Objective-C, no Swift :(
  • 15. Armed to the teeth #1: Code style Clang-Format
  • 16. Armed to the teeth #1: Code style • Pre-commit hooks: ocstyle, SwiftFormat, SpaceCommander (uses Clang-Format) & more on GitHub. • Some check in SwiftLint
  • 17. Armed to the teeth #1: Code style AppCode • Settings for Objective-C, C, C+ +, Swift. • Reformat action • On-the-fly • Format on commit stage
  • 18. Armed to the teeth #2: Generate code • Xcode pre-generates some methods when creating files/classes. • Xcode code snippets for Objective-C and Swift. • Override/Implement code generation on completion in Xcode. • There were some 3d-party tools like xobjc on GitHub.
  • 19. Armed to the teeth #2: Generate code AppCode: • Generate menu • Live Templates • Create from usage • Override/Implement • File Templates
  • 20. Armed to the teeth #3: Static analysis Tools: • Guidelines/rules • Configuration settings • On-the-fly mode • Quick fixes
  • 21. Armed to the teeth #3: Static analysis Clang analyzer: • Open source, part of Clang project • Integrated into Xcode • Basic checks, dead code, API checks, language specific checks But don’t forget to switch them all on!
  • 22. Armed to the teeth #3: Static analysis OCLint: https://github.com/oclint • Metric-based defects: • complicated code; • redundant code; • long methods, long parameters lists, etc.; • bad practices (like parameter reassignment). • 58 rules that can be customized per project • Integrated with clang analyzer • Can be used inside the Xcode
  • 23. Armed to the teeth #3: Static analysis SwiftLint: https://github.com/realm/SwiftLint • Similar to OCLint • Limited in number of rules, planned rules: • Code style checks (spaces, newlines); • let over var rule; struct over classes; • Working with optionals (like not forcing unwrapping); • Specify access control and more. • Contribute!
  • 24. Armed to the teeth #3: Static analysis OCLint and SwiftLint
  • 25. Armed to the teeth #3: Static analysis OCLint and SwiftLint
  • 26. Armed to the teeth #3: Static analysis AppCode • Integrated with clang analyzer • 60 inspections for Objective-C, 40 for C/ C++, on-the-fly mode • Settings, severity level, profiles
  • 27. Armed to the teeth #3: Static analysis AppCode: complicated cases, bulk mode
  • 28. Armed to the teeth #3: Static analysis AppCode: quick fixes, DFA
  • 29. Armed to the teeth #3: Static analysis AppCode: Checks on commit stage • formatter • code analysis • TODO • imports
  • 30. Armed to the teeth #4: Refactoring • Xcode refactorings • Rename, Extract (method/function), Move up/down, Create superclass, Encapsulate, Convert… • C and Objective-C only • AppCode refactorings • + Inline, Safe delete, Change signature, Extract everything, Rename with non-code usages (strings, comment, xib, etc.) for Objective-C, C, C++ • Rename in Swift • Some projects on GitHub, like Refactorial
  • 31. Armed to the teeth #5: Unit testing • XCTest • Kiwi: BDD framework for Objective-C • Google Test: tests for C/C++ • Specta/Expecta: TDD / BDD framework for Objective-C • Quick/Nimble: Swift BDD framework
  • 32. Armed to the teeth #5: Unit testing AppCode: unit tests code generation
  • 33. Summary TODO: • Follow selected code style • Generate standard pieces of code • Use the swiss-army knife thoughtfully to find smells • Refactor to clean up the smells • Cover every inch with the unit tests Tools: • Xcode • Clang-Format • OC/Swift-Lint • AppCode
  • 34. Thanks for listening! Anastasia.Kazakova@jetbrains.com @anastasiak2512 IDE for iOS/OS X dev: http://jetbrains.com/appcode, @appcode