SlideShare une entreprise Scribd logo
1  sur  48
Télécharger pour lire hors ligne
Qualidade
A Panacéia para seu código Elixir
Hello!
Weverton Timoteo
@wevtimoteo
● Very useful item to up your RPG
character level
● I’d recommend to buy at least 5
● Drops from some medium level
mobs
Panacea
● Was a goddess of universal remedy
● Panacea traditionally had a potion
with which she healed the sick
● A substance meant to cure all
diseases
● "Something used to solve all
problems"
Panacea (from Greek mythology)
“
Any fool can write code that a
computer can understand.
Good programmers write code that
humans can understand.
– Martin Fowler
How Do You Define
“Good Code” ?
maintainability?
Efficiency Modularity Elegance
What's the first thing that comes to your
mind?
Proper design
decision
You write readable code because it helps other
people to read your code“
Code Complete, Steve McConnel
Error rate
Comprehensibility
Reviewability
Debugging
Modifiability
Simplicity
is it about the number of lines?
Readability
comments, conventions, naming
Modularity
its all about reusability
Layering
attention to the boundaries of each layer
Design
plan before build
Efficiency
too many connections?
Elegance
solve problems with proper solutions
Clarity
do you really know what you have to do?
Balance
How to achieve
this?
● Erlang Open Telecom Protocol
● it's not that much about telecom anymore
● libraries available with the virtual machine
● OTP compliant: basically following process architecture
OTP (Open Telecom Protocol)
BEAM
● Bogdan's Erlang Abstract Machine
○ emulator and loader were first implemented by Bogumil Hausman
● Björn's Erlang Abstract Machine
○ completely rewritten by Björn Gustavsson
● BEAM bytecode files have the .beam file extension
● Static analysis tool that identifies software
discrepancies, such as:
○ definite type errors
○ code that has become dead
○ unreachable because of programming error
○ unnecessary tests
● Erlang modules or entire (sets of) applications
(.beam files)
DIscrepancy AnaLYZer for ERlang programs
DIALYZER
The Persistent Lookup Table (PLT)
● Stores the result of an analysis (acting like a cache)
● Then it can be used as starting point for later analyses
● .plt file extension
Gradual Typing
Best of Static and Dynamic Worlds:
● Some variables and functions can have type declaration
● Developer decides which ones makes sense to declare
● Tool or Compiler can still check correctness and consistency of
usage
● It allows us to generate tests from the code
examples in a module/function/macro's
documentation
● Similar to Python's doctest
● Able to refer to specific numbered scenarios
● Copy-pasting examples from an actual IEx session
Doctests
● Run Dialyzer (test environment) to see how the
types in API and the usage in the tests (calls)
Using Dialyzer for tests
Dialyzer (Cons)
● Output in Erlang format
● No indentation
● No formatting
Dialixyr
Mix tasks to simplify use of
Dialyzer in Elixir projects
Dialixyr - Explain
Dialixyr - Explain
Dialixyr - Explain
Dialixyr - Ignore file
is a tool that analyzes source code to flag
programming errors, bugs, stylistic errors,
and suspicious constructs
- Wikipedia
What is a linter?
“
Homoiconicity
● The code used to express a program is
written using the data structures of
that language
● The Lisp family languages (Common
Lisp, Scheme, Clojure, etc)
● Code is Data, Data is Code
Abstract Syntax Tree (AST)
● It tells us how expressions are represented
● Internal representation of our code
● Using quote/2 we can convert Elixir code into its
representation
AST: quote/2
Using quote/2 we can convert Elixir code into its representation
Is Elixir Homoiconic?
No!
If so:
● We would be writing in ASTs form
● It would bypass the lexing and parsing phase of Elixir compilation
● Formats the given files and patterns
Code Formatting
● Code Complexity (Cyclomatic Complexity, etc)
● Style and Pattern Checking
● Performance
● Unused code
● Reports
● Outdated packages
● Code without tests (no coverage)
● Magic number detector
What a Linter can do?
Dogma
Credo
● Also static analysis tool
● Checks
○ code consistency
○ readability
○ styleguides
○ conventions
● Useful for learning
mix credo categories
mix credo categories
Credo
And if all checks
succeed ?
Thanks!Let’s start analyzing
our code!
|> team
|> hiring()
References
● Code Complete: A Practical Handbook of Software Construction
● Elixir, processes and this thing called OTP
● Introducing HDD: Hughes Driven Development, com José Valim
● Credo
● Dialyzer
● Dialixyr
● Ebert: the code review assistant for your organization
● Metaprogramming in Elixir
More References
● ElixirConf 2016 - Dialyzer: Optimistic Type Checking for Erlang and Elixir
by Jason Voegele
● Gradualizer: A Gradual Type System for Erlang
● Learn You Some Erlang: OTP

Contenu connexe

Tendances

C# 4.0 and .NET 4.0
C# 4.0 and .NET 4.0C# 4.0 and .NET 4.0
C# 4.0 and .NET 4.0
Buu Nguyen
 
Devoxx 2013 Summary/Keynotes
Devoxx 2013 Summary/KeynotesDevoxx 2013 Summary/Keynotes
Devoxx 2013 Summary/Keynotes
Aliaksandr Kazlou
 
Clean code, Feb 2012
Clean code, Feb 2012Clean code, Feb 2012
Clean code, Feb 2012
cobyst
 

Tendances (20)

Importance of the quality of code
Importance of the quality of codeImportance of the quality of code
Importance of the quality of code
 
What do we really know about the differences between static and dynamic types?
What do we really know about the differences between static and dynamic types?What do we really know about the differences between static and dynamic types?
What do we really know about the differences between static and dynamic types?
 
C# 4.0 and .NET 4.0
C# 4.0 and .NET 4.0C# 4.0 and .NET 4.0
C# 4.0 and .NET 4.0
 
Python type hints
Python type hintsPython type hints
Python type hints
 
Devoxx 2013 Summary/Keynotes
Devoxx 2013 Summary/KeynotesDevoxx 2013 Summary/Keynotes
Devoxx 2013 Summary/Keynotes
 
ANTLR4 and its testing
ANTLR4 and its testingANTLR4 and its testing
ANTLR4 and its testing
 
Deep learning for NLP and Transformer
 Deep learning for NLP  and Transformer Deep learning for NLP  and Transformer
Deep learning for NLP and Transformer
 
Introduction to Transformer Model
Introduction to Transformer ModelIntroduction to Transformer Model
Introduction to Transformer Model
 
Clean Code
Clean CodeClean Code
Clean Code
 
Code Quality
Code QualityCode Quality
Code Quality
 
Data Generation with PROSPECT: a Probability Specification Tool
Data Generation with PROSPECT: a Probability Specification ToolData Generation with PROSPECT: a Probability Specification Tool
Data Generation with PROSPECT: a Probability Specification Tool
 
Coding standards and guidelines
Coding standards and guidelinesCoding standards and guidelines
Coding standards and guidelines
 
Python lecture 01
Python lecture 01Python lecture 01
Python lecture 01
 
PL Lecture 01 - preliminaries
PL Lecture 01 - preliminariesPL Lecture 01 - preliminaries
PL Lecture 01 - preliminaries
 
Clean code, Feb 2012
Clean code, Feb 2012Clean code, Feb 2012
Clean code, Feb 2012
 
Coding standards
Coding standardsCoding standards
Coding standards
 
Documenting code yapceu2016
Documenting code yapceu2016Documenting code yapceu2016
Documenting code yapceu2016
 
Python Programming
Python ProgrammingPython Programming
Python Programming
 
PL Lecture 02 - Binding and Scope
PL Lecture 02 - Binding and ScopePL Lecture 02 - Binding and Scope
PL Lecture 02 - Binding and Scope
 
Documenting Code - Patterns and Anti-patterns - NLPW 2016
Documenting Code - Patterns and Anti-patterns - NLPW 2016Documenting Code - Patterns and Anti-patterns - NLPW 2016
Documenting Code - Patterns and Anti-patterns - NLPW 2016
 

Similaire à Elixir Brasil 2019 - Quality: A Panacéia para seu código Elixir

Python Mastery: A Comprehensive Guide to Setting Up Your Development Environment
Python Mastery: A Comprehensive Guide to Setting Up Your Development EnvironmentPython Mastery: A Comprehensive Guide to Setting Up Your Development Environment
Python Mastery: A Comprehensive Guide to Setting Up Your Development Environment
Python Devloper
 
Programming Languages #devcon2013
Programming Languages #devcon2013Programming Languages #devcon2013
Programming Languages #devcon2013
Iván Montes
 
Algorithm and pseudo codes
Algorithm and pseudo codesAlgorithm and pseudo codes
Algorithm and pseudo codes
hermiraguilar
 

Similaire à Elixir Brasil 2019 - Quality: A Panacéia para seu código Elixir (20)

Quick Intro to Clean Coding
Quick Intro to Clean CodingQuick Intro to Clean Coding
Quick Intro to Clean Coding
 
Lecture 1 introduction to language processors
Lecture 1  introduction to language processorsLecture 1  introduction to language processors
Lecture 1 introduction to language processors
 
Software Craftmanship - Cours Polytech
Software Craftmanship - Cours PolytechSoftware Craftmanship - Cours Polytech
Software Craftmanship - Cours Polytech
 
Principles of Compiler Design - Introduction
Principles of Compiler Design - IntroductionPrinciples of Compiler Design - Introduction
Principles of Compiler Design - Introduction
 
Ic lecture8
Ic lecture8 Ic lecture8
Ic lecture8
 
Introduction to programming c
Introduction to programming cIntroduction to programming c
Introduction to programming c
 
Python Mastery: A Comprehensive Guide to Setting Up Your Development Environment
Python Mastery: A Comprehensive Guide to Setting Up Your Development EnvironmentPython Mastery: A Comprehensive Guide to Setting Up Your Development Environment
Python Mastery: A Comprehensive Guide to Setting Up Your Development Environment
 
Trans coder
Trans coderTrans coder
Trans coder
 
EMPEX LA 2018 - Inclusion Starts with Docs
EMPEX LA 2018 - Inclusion Starts with DocsEMPEX LA 2018 - Inclusion Starts with Docs
EMPEX LA 2018 - Inclusion Starts with Docs
 
Programming Languages #devcon2013
Programming Languages #devcon2013Programming Languages #devcon2013
Programming Languages #devcon2013
 
Working With Legacy Code
Working With Legacy CodeWorking With Legacy Code
Working With Legacy Code
 
Half-automatic Compilable Source Code Recovery
Half-automatic Compilable Source Code RecoveryHalf-automatic Compilable Source Code Recovery
Half-automatic Compilable Source Code Recovery
 
1 cc
1 cc1 cc
1 cc
 
Design Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesDesign Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best Practices
 
Computer programing 111 lecture 1
Computer programing 111 lecture 1 Computer programing 111 lecture 1
Computer programing 111 lecture 1
 
Algorithm and pseudo codes
Algorithm and pseudo codesAlgorithm and pseudo codes
Algorithm and pseudo codes
 
Design Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesDesign Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best Practices
 
Compiler an overview
Compiler  an overviewCompiler  an overview
Compiler an overview
 
NANO266 - Lecture 9 - Tools of the Modeling Trade
NANO266 - Lecture 9 - Tools of the Modeling TradeNANO266 - Lecture 9 - Tools of the Modeling Trade
NANO266 - Lecture 9 - Tools of the Modeling Trade
 
Compilers.pptx
Compilers.pptxCompilers.pptx
Compilers.pptx
 

Plus de Weverton Timoteo

Plus de Weverton Timoteo (18)

[Ruby Summit Brasil 2020] Ruby 3 e Análise estática - O que esperar e o que s...
[Ruby Summit Brasil 2020] Ruby 3 e Análise estática - O que esperar e o que s...[Ruby Summit Brasil 2020] Ruby 3 e Análise estática - O que esperar e o que s...
[Ruby Summit Brasil 2020] Ruby 3 e Análise estática - O que esperar e o que s...
 
[Devs Cansados Evento 2020] Queria saber a qualidade do meu código: o que olho?
[Devs Cansados Evento 2020] Queria saber a qualidade do meu código: o que olho?[Devs Cansados Evento 2020] Queria saber a qualidade do meu código: o que olho?
[Devs Cansados Evento 2020] Queria saber a qualidade do meu código: o que olho?
 
[CodeBEAM BR 2020] Construindo e Distribuindo CLIs com Elixir
[CodeBEAM BR 2020] Construindo e Distribuindo CLIs com Elixir[CodeBEAM BR 2020] Construindo e Distribuindo CLIs com Elixir
[CodeBEAM BR 2020] Construindo e Distribuindo CLIs com Elixir
 
Ruby 3 e Análise estática - O que esperar e o que significa para o nosso código
Ruby 3 e Análise estática - O que esperar e o que significa para o nosso códigoRuby 3 e Análise estática - O que esperar e o que significa para o nosso código
Ruby 3 e Análise estática - O que esperar e o que significa para o nosso código
 
[Gophercon 2019] Analysing code quality with linters and static analysis
[Gophercon 2019] Analysing code quality with linters and static analysis[Gophercon 2019] Analysing code quality with linters and static analysis
[Gophercon 2019] Analysing code quality with linters and static analysis
 
Floripa Gophers - Analysing Code Quality (Linters and Static Analysis)
Floripa Gophers - Analysing Code Quality (Linters and Static Analysis)Floripa Gophers - Analysing Code Quality (Linters and Static Analysis)
Floripa Gophers - Analysing Code Quality (Linters and Static Analysis)
 
21o. RubyFloripa - Maintaining legacy Rails app and introducing Elixir
21o. RubyFloripa - Maintaining legacy Rails app and introducing Elixir21o. RubyFloripa - Maintaining legacy Rails app and introducing Elixir
21o. RubyFloripa - Maintaining legacy Rails app and introducing Elixir
 
How to use Ruby code inside Elixir
How to use Ruby code inside ElixirHow to use Ruby code inside Elixir
How to use Ruby code inside Elixir
 
17º RubyFloripa - Coding Dojo
17º RubyFloripa - Coding Dojo17º RubyFloripa - Coding Dojo
17º RubyFloripa - Coding Dojo
 
How to draw a map - What is projections?
How to draw a map - What is projections?How to draw a map - What is projections?
How to draw a map - What is projections?
 
Gerenciando dependências front-end no Rails
Gerenciando dependências front-end no RailsGerenciando dependências front-end no Rails
Gerenciando dependências front-end no Rails
 
Definindo a quantidade de workers para sua app
Definindo a quantidade de workers para sua appDefinindo a quantidade de workers para sua app
Definindo a quantidade de workers para sua app
 
Introdução ao Chef Ops
Introdução ao Chef OpsIntrodução ao Chef Ops
Introdução ao Chef Ops
 
Brincando com FFI no Ruby
Brincando com FFI no RubyBrincando com FFI no Ruby
Brincando com FFI no Ruby
 
Como definir a quantidade de workers para sua aplicação
Como definir a quantidade de workers para sua aplicaçãoComo definir a quantidade de workers para sua aplicação
Como definir a quantidade de workers para sua aplicação
 
Swift language - A fast overview of some features
Swift language - A fast overview of some featuresSwift language - A fast overview of some features
Swift language - A fast overview of some features
 
Vim Registers
Vim RegistersVim Registers
Vim Registers
 
Developing an Universal iOS app
Developing an Universal iOS appDeveloping an Universal iOS app
Developing an Universal iOS app
 

Dernier

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Dernier (20)

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
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
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
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
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
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
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
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...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

Elixir Brasil 2019 - Quality: A Panacéia para seu código Elixir