SlideShare uma empresa Scribd logo
1 de 34
Baixar para ler offline
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

Mais conteúdo relacionado

Mais procurados

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 UpSourceOleksii Prohonnyi
 
Clean Code III - Software Craftsmanship
Clean Code III - Software CraftsmanshipClean Code III - Software Craftsmanship
Clean Code III - Software CraftsmanshipTheo Jungeblut
 
Code Review: How and When
Code Review: How and WhenCode Review: How and When
Code Review: How and WhenPaul Gower
 
Code Review
Code ReviewCode Review
Code ReviewTu Hoang
 
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 WhenPaul Gower
 
Code Review Tool Evaluation
Code Review Tool EvaluationCode Review Tool Evaluation
Code Review Tool EvaluationKate 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_javaManimekalai48
 
Top 10 static code analysis tool
Top 10 static code analysis toolTop 10 static code analysis tool
Top 10 static code analysis toolscmGalaxy 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 MAgile Testing Alliance
 
Coding Standard And Code Review
Coding Standard And Code ReviewCoding Standard And Code Review
Coding Standard And Code ReviewMilan Vukoje
 
Functional Tests Automation with Robot Framework
Functional Tests Automation with Robot FrameworkFunctional Tests Automation with Robot Framework
Functional Tests Automation with Robot Frameworklaurent bristiel
 

Mais procurados (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
 

Destaque

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óndoourense
 
Lisans Diploması
Lisans DiplomasıLisans Diploması
Lisans DiplomasıSalih Guner
 
Off the rails
Off the railsOff the rails
Off the rails101k_
 
Revisão: Absolutismo e Reforma Religiosas
Revisão: Absolutismo e Reforma ReligiosasRevisão: Absolutismo e Reforma Religiosas
Revisão: Absolutismo e Reforma ReligiosasValderiVini
 
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 ConsumerCognizant
 
Advice on academic writing
Advice on academic writingAdvice on academic writing
Advice on academic writingMariana 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 pointCognizant
 
Scleromarketing | BTO 2016 | Tiziana Tirelli
Scleromarketing | BTO 2016 | Tiziana TirelliScleromarketing | BTO 2016 | Tiziana Tirelli
Scleromarketing | BTO 2016 | Tiziana TirelliBTO Educational
 
Proposal kejurda bjb cup
Proposal kejurda bjb cup Proposal kejurda bjb cup
Proposal kejurda bjb cup OPTISIMUS
 
TRADE_DETERGENTI_AUTO_Lancellotti_Invernizzi
TRADE_DETERGENTI_AUTO_Lancellotti_InvernizziTRADE_DETERGENTI_AUTO_Lancellotti_Invernizzi
TRADE_DETERGENTI_AUTO_Lancellotti_InvernizziRoberto Lancellotti
 
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 Kumarohscmcvellore
 

Destaque (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
 

Semelhante a 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-CAaron 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.pptxGauravGamer2
 
Static-Analysis-in-Industry.pptx
Static-Analysis-in-Industry.pptxStatic-Analysis-in-Industry.pptx
Static-Analysis-in-Industry.pptxShivashankarHR1
 
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 developerJuan 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 ProgrammingLazar 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 SwiftJordan Yaker
 
iOS Development Gems in AppCode
iOS Development Gems in AppCodeiOS Development Gems in AppCode
iOS Development Gems in AppCodeAlexey Ushakov
 
«iOS Development Gems in AppCode» — Алексей Ушаков, JetBrains
«iOS Development Gems in AppCode» — Алексей Ушаков, JetBrains«iOS Development Gems in AppCode» — Алексей Ушаков, JetBrains
«iOS Development Gems in AppCode» — Алексей Ушаков, JetBrainse-Legion
 
How to write good quality code
How to write good quality codeHow to write good quality code
How to write good quality codeHayden 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 CampTheo Jungeblut
 
How To Use Selenium Successfully
How To Use Selenium SuccessfullyHow To Use Selenium Successfully
How To Use Selenium SuccessfullyDave 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štInfinum
 
Developer Job in Practice
Developer Job in PracticeDeveloper Job in Practice
Developer Job in Practiceintive
 
Bootstrapping iPhone Development
Bootstrapping iPhone DevelopmentBootstrapping iPhone Development
Bootstrapping iPhone DevelopmentThoughtWorks
 
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 ProgrammingPostSharp Technologies
 

Semelhante a 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
 

Último

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 

Último (20)

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

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