SlideShare una empresa de Scribd logo
Nasir Jamal (a.k.a. nas) LCN.com
Code Sense Writing better Code
Ruby
[object Object],[object Object],[object Object],[object Object],[object Object]
Disclaimer I am talking about how to write good quality code but that does not mean that I always write perfect code. I do slip to the dark side sometimes.
How would you measure the quality of code?
http://www.osnews.com/story/19266/WTFs_m
Some ruby code What do you think about this code?
Problems in the code ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Add new functionality or change the flow of the same code
Options ,[object Object],[object Object],[object Object]
Refactoring Change internal structure of the code without changing it's observable behaviour.
Why refactoring? Any code that is difficult to understand and restricts adding new functionality to it or extending, needs refactoring.
Comparison ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Basics ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Basics ,[object Object],[object Object],[object Object],[object Object]
Thank you  Q? twitter.com/_nasj nasir.wordpress.com github.com/nas stackoverflow.com/users/200486/nas

Más contenido relacionado

La actualidad más candente

Exceptions: Why, When, How and Where!
Exceptions: Why, When, How and Where!Exceptions: Why, When, How and Where!
Exceptions: Why, When, How and Where!Hernan Wilkinson
 
Competitive Programming Guide
Competitive Programming GuideCompetitive Programming Guide
Competitive Programming GuideAjay Khatri
 
Session 3 : Competitive programming 1
Session 3 : Competitive programming 1Session 3 : Competitive programming 1
Session 3 : Competitive programming 1Koderunners
 
7 rules on code readability
7 rules on code readability7 rules on code readability
7 rules on code readabilityPer Lundholm
 
Code Smells and Refactoring - Satyajit Dey & Ashif Iqbal
Code Smells and Refactoring - Satyajit Dey & Ashif IqbalCode Smells and Refactoring - Satyajit Dey & Ashif Iqbal
Code Smells and Refactoring - Satyajit Dey & Ashif IqbalCefalo
 
SMU BCA SPRING 2014 SOLVED ASSIGNMENTS SEM-5
SMU BCA SPRING 2014  SOLVED ASSIGNMENTS SEM-5SMU BCA SPRING 2014  SOLVED ASSIGNMENTS SEM-5
SMU BCA SPRING 2014 SOLVED ASSIGNMENTS SEM-5smumbahelp
 
Introduction to Competitive programming
Introduction to Competitive programmingIntroduction to Competitive programming
Introduction to Competitive programmingAyoub Eddakhly
 
Improving Code Completion in Pharo
Improving Code Completion in PharoImproving Code Completion in Pharo
Improving Code Completion in PharoESUG
 
SMU BCA SPRING 2014 SOLVED ASSIGNMENTS SEM-2
SMU BCA SPRING 2014  SOLVED ASSIGNMENTS SEM-2SMU BCA SPRING 2014  SOLVED ASSIGNMENTS SEM-2
SMU BCA SPRING 2014 SOLVED ASSIGNMENTS SEM-2smumbahelp
 
What is an algorithm?
What is an algorithm?What is an algorithm?
What is an algorithm?Angela DeHart
 
Design byexceptions
Design byexceptionsDesign byexceptions
Design byexceptionsAsif Tasleem
 
Mca2030 object oriented programming – c++
Mca2030  object oriented programming – c++Mca2030  object oriented programming – c++
Mca2030 object oriented programming – c++smumbahelp
 
Leaping over the Boundaries of Boundary Value Analysis
Leaping over the Boundaries of Boundary Value AnalysisLeaping over the Boundaries of Boundary Value Analysis
Leaping over the Boundaries of Boundary Value AnalysisTechWell
 
Unit testing - the hard parts
Unit testing - the hard partsUnit testing - the hard parts
Unit testing - the hard partsShaun Abram
 
Smu bsc it solved assignments 2104 sem -6th
Smu bsc it solved assignments 2104  sem -6thSmu bsc it solved assignments 2104  sem -6th
Smu bsc it solved assignments 2104 sem -6thsmumbahelp
 
QA Best Practices
QA  Best PracticesQA  Best Practices
QA Best PracticesJames York
 

La actualidad más candente (19)

Exceptions: Why, When, How and Where!
Exceptions: Why, When, How and Where!Exceptions: Why, When, How and Where!
Exceptions: Why, When, How and Where!
 
Tdd
TddTdd
Tdd
 
Clean code
Clean codeClean code
Clean code
 
Competitive Programming Guide
Competitive Programming GuideCompetitive Programming Guide
Competitive Programming Guide
 
Session 3 : Competitive programming 1
Session 3 : Competitive programming 1Session 3 : Competitive programming 1
Session 3 : Competitive programming 1
 
7 rules on code readability
7 rules on code readability7 rules on code readability
7 rules on code readability
 
Abstract class
Abstract classAbstract class
Abstract class
 
Code Smells and Refactoring - Satyajit Dey & Ashif Iqbal
Code Smells and Refactoring - Satyajit Dey & Ashif IqbalCode Smells and Refactoring - Satyajit Dey & Ashif Iqbal
Code Smells and Refactoring - Satyajit Dey & Ashif Iqbal
 
SMU BCA SPRING 2014 SOLVED ASSIGNMENTS SEM-5
SMU BCA SPRING 2014  SOLVED ASSIGNMENTS SEM-5SMU BCA SPRING 2014  SOLVED ASSIGNMENTS SEM-5
SMU BCA SPRING 2014 SOLVED ASSIGNMENTS SEM-5
 
Introduction to Competitive programming
Introduction to Competitive programmingIntroduction to Competitive programming
Introduction to Competitive programming
 
Improving Code Completion in Pharo
Improving Code Completion in PharoImproving Code Completion in Pharo
Improving Code Completion in Pharo
 
SMU BCA SPRING 2014 SOLVED ASSIGNMENTS SEM-2
SMU BCA SPRING 2014  SOLVED ASSIGNMENTS SEM-2SMU BCA SPRING 2014  SOLVED ASSIGNMENTS SEM-2
SMU BCA SPRING 2014 SOLVED ASSIGNMENTS SEM-2
 
What is an algorithm?
What is an algorithm?What is an algorithm?
What is an algorithm?
 
Design byexceptions
Design byexceptionsDesign byexceptions
Design byexceptions
 
Mca2030 object oriented programming – c++
Mca2030  object oriented programming – c++Mca2030  object oriented programming – c++
Mca2030 object oriented programming – c++
 
Leaping over the Boundaries of Boundary Value Analysis
Leaping over the Boundaries of Boundary Value AnalysisLeaping over the Boundaries of Boundary Value Analysis
Leaping over the Boundaries of Boundary Value Analysis
 
Unit testing - the hard parts
Unit testing - the hard partsUnit testing - the hard parts
Unit testing - the hard parts
 
Smu bsc it solved assignments 2104 sem -6th
Smu bsc it solved assignments 2104  sem -6thSmu bsc it solved assignments 2104  sem -6th
Smu bsc it solved assignments 2104 sem -6th
 
QA Best Practices
QA  Best PracticesQA  Best Practices
QA Best Practices
 

Destacado

Non solo blog: Wordpress usabile e accessibile
Non solo blog: Wordpress usabile e accessibileNon solo blog: Wordpress usabile e accessibile
Non solo blog: Wordpress usabile e accessibileTommaso Baldovino
 
Witold kula teoria eocnomica del sistema feudal
Witold kula   teoria eocnomica del sistema feudalWitold kula   teoria eocnomica del sistema feudal
Witold kula teoria eocnomica del sistema feudalCiocio Sam
 
Cuento colaborativo
Cuento colaborativoCuento colaborativo
Cuento colaborativoasunsita
 
Wordpress per una community?
Wordpress per una community?Wordpress per una community?
Wordpress per una community?Tommaso Baldovino
 
Presentation from Seville
Presentation from SevillePresentation from Seville
Presentation from Sevilleasunsita
 
9° expo terapia combinada
9° expo   terapia combinada9° expo   terapia combinada
9° expo terapia combinadalimylujan
 

Destacado (8)

Wake Album
Wake AlbumWake Album
Wake Album
 
Non solo blog: Wordpress usabile e accessibile
Non solo blog: Wordpress usabile e accessibileNon solo blog: Wordpress usabile e accessibile
Non solo blog: Wordpress usabile e accessibile
 
Witold kula teoria eocnomica del sistema feudal
Witold kula   teoria eocnomica del sistema feudalWitold kula   teoria eocnomica del sistema feudal
Witold kula teoria eocnomica del sistema feudal
 
Cuento colaborativo
Cuento colaborativoCuento colaborativo
Cuento colaborativo
 
Wordpress per una community?
Wordpress per una community?Wordpress per una community?
Wordpress per una community?
 
The News is Not Fun
The News is Not FunThe News is Not Fun
The News is Not Fun
 
Presentation from Seville
Presentation from SevillePresentation from Seville
Presentation from Seville
 
9° expo terapia combinada
9° expo   terapia combinada9° expo   terapia combinada
9° expo terapia combinada
 

Similar a Code sense

[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...DevDay.org
 
Clean code, Feb 2012
Clean code, Feb 2012Clean code, Feb 2012
Clean code, Feb 2012cobyst
 
TDD Walkthrough - Encryption
TDD Walkthrough - EncryptionTDD Walkthrough - Encryption
TDD Walkthrough - EncryptionPeterKha2
 
Ddc2011 효과적으로레거시코드다루기
Ddc2011 효과적으로레거시코드다루기Ddc2011 효과적으로레거시코드다루기
Ddc2011 효과적으로레거시코드다루기Myeongseok Baek
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Developmentbhochhi
 
Code Review Looking for a vulnerable code. Vlad Savitsky.
Code Review Looking for a vulnerable code. Vlad Savitsky.Code Review Looking for a vulnerable code. Vlad Savitsky.
Code Review Looking for a vulnerable code. Vlad Savitsky.DrupalCampDN
 
Code Smell and Refactoring
Code Smell and RefactoringCode Smell and Refactoring
Code Smell and Refactoringkimsrung lov
 
Clean code - DSC DYPCOE
Clean code - DSC DYPCOEClean code - DSC DYPCOE
Clean code - DSC DYPCOEPatil Shreyas
 
Raya code quality guidelines - enhancing readability
Raya code quality guidelines - enhancing readabilityRaya code quality guidelines - enhancing readability
Raya code quality guidelines - enhancing readabilityAbdel Hady Muhammad
 
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...mCloud
 
Coding Best Practices.docx
Coding Best Practices.docxCoding Best Practices.docx
Coding Best Practices.docxShitanshuKumar15
 
clean code book summary - uncle bob - English version
clean code book summary - uncle bob - English versionclean code book summary - uncle bob - English version
clean code book summary - uncle bob - English versionsaber tabatabaee
 
Improving your code design using Java
Improving your code design using JavaImproving your code design using Java
Improving your code design using JavaRoan Brasil Monteiro
 
Principled And Clean Coding
Principled And Clean CodingPrincipled And Clean Coding
Principled And Clean CodingMetin Ogurlu
 
Bad Code Smells
Bad Code SmellsBad Code Smells
Bad Code Smellskim.mens
 
Code Review
Code ReviewCode Review
Code ReviewRavi Raj
 
Perfomatix - iOS swift coding standards
Perfomatix - iOS swift coding standardsPerfomatix - iOS swift coding standards
Perfomatix - iOS swift coding standardsPerfomatix Solutions
 

Similar a Code sense (20)

[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
 
Clean code, Feb 2012
Clean code, Feb 2012Clean code, Feb 2012
Clean code, Feb 2012
 
TDD Walkthrough - Encryption
TDD Walkthrough - EncryptionTDD Walkthrough - Encryption
TDD Walkthrough - Encryption
 
Ddc2011 효과적으로레거시코드다루기
Ddc2011 효과적으로레거시코드다루기Ddc2011 효과적으로레거시코드다루기
Ddc2011 효과적으로레거시코드다루기
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Code Review Looking for a vulnerable code. Vlad Savitsky.
Code Review Looking for a vulnerable code. Vlad Savitsky.Code Review Looking for a vulnerable code. Vlad Savitsky.
Code Review Looking for a vulnerable code. Vlad Savitsky.
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Code Smell and Refactoring
Code Smell and RefactoringCode Smell and Refactoring
Code Smell and Refactoring
 
Clean code - DSC DYPCOE
Clean code - DSC DYPCOEClean code - DSC DYPCOE
Clean code - DSC DYPCOE
 
Raya code quality guidelines - enhancing readability
Raya code quality guidelines - enhancing readabilityRaya code quality guidelines - enhancing readability
Raya code quality guidelines - enhancing readability
 
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
 
Coding Best Practices.docx
Coding Best Practices.docxCoding Best Practices.docx
Coding Best Practices.docx
 
clean code book summary - uncle bob - English version
clean code book summary - uncle bob - English versionclean code book summary - uncle bob - English version
clean code book summary - uncle bob - English version
 
Improving your code design using Java
Improving your code design using JavaImproving your code design using Java
Improving your code design using Java
 
Principled And Clean Coding
Principled And Clean CodingPrincipled And Clean Coding
Principled And Clean Coding
 
Code Metrics
Code MetricsCode Metrics
Code Metrics
 
Bad Code Smells
Bad Code SmellsBad Code Smells
Bad Code Smells
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Code Review
Code ReviewCode Review
Code Review
 
Perfomatix - iOS swift coding standards
Perfomatix - iOS swift coding standardsPerfomatix - iOS swift coding standards
Perfomatix - iOS swift coding standards
 

Último

Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCustom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCzechDreamin
 
Top 10 Symfony Development Companies 2024
Top 10 Symfony Development Companies 2024Top 10 Symfony Development Companies 2024
Top 10 Symfony Development Companies 2024TopCSSGallery
 
Connecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAKConnecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAKUXDXConf
 
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfSimplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfFIDO Alliance
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...CzechDreamin
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfFIDO Alliance
 
Agentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdfAgentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdfChristopherTHyatt
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...FIDO Alliance
 
Strategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering TeamsStrategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering TeamsUXDXConf
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeCzechDreamin
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyJohn Staveley
 
Buy Epson EcoTank L3210 Colour Printer Online.pptx
Buy Epson EcoTank L3210 Colour Printer Online.pptxBuy Epson EcoTank L3210 Colour Printer Online.pptx
Buy Epson EcoTank L3210 Colour Printer Online.pptxEasyPrinterHelp
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaCzechDreamin
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...CzechDreamin
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxAbida Shariff
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutesconfluent
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FIDO Alliance
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityScyllaDB
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераMark Opanasiuk
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekCzechDreamin
 

Último (20)

Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCustom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
 
Top 10 Symfony Development Companies 2024
Top 10 Symfony Development Companies 2024Top 10 Symfony Development Companies 2024
Top 10 Symfony Development Companies 2024
 
Connecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAKConnecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAK
 
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfSimplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
Agentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdfAgentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdf
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
Strategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering TeamsStrategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering Teams
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
Buy Epson EcoTank L3210 Colour Printer Online.pptx
Buy Epson EcoTank L3210 Colour Printer Online.pptxBuy Epson EcoTank L3210 Colour Printer Online.pptx
Buy Epson EcoTank L3210 Colour Printer Online.pptx
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 

Code sense

Notas del editor

  1. I am going to talk about some common sense approach to code quality, ie. Code sense . How we can take some basic measures to make sure that the code we write is of sufficiently good quality and that makes sense to us when we come back to it after a week, month or even to any one new to that code.
  2. And I will be using ruby to demonstrate that because I use ruby to code and I think it is an elegant, very flexible and pure object oriented language. Everything in ruby is an object even the integers. What that means is you can pass messages to integers, i.e. call methods on them for exampe
  3. Integer 12 is an instance of class Fixnum. I can pass it messages like class to find out what type of object it is, modulo, to_s and to_f to convert it to string or float. This looks and sounds very simple but if you think of it then this becomes very powerful when it comes to do metaprogramming i.e. programs that can generate programs dynamically. Thats enough for ruby, if you want to know more about ruby then catch me after the talk
  4. I am gonna talk about how to write good quality code but that doesnt mean that I always write perfect code. I do slip to the dark side but every good programmer knows that they rarely write good code in the first instance. I will come back to this later during my talk.
  5. Measuring code quality is very subjective because the code that is of sufficiently good quality for me may be of very bad quality for someone else. You can only measure code in relative terms. Though there are tools available to check the cyclomatic complexity, code duplication, test coverage, structural similarity, etc. For instance, in ruby world we have a library/gem available called metric_fu that people who care about code quality use to get some metrics on code. Can anyone give me some idea like given some code how would you measure its quality I think the image on the next slide shows the best way to measure code quality.
  6. Show code I will show you some code that has been used on an ecommerce site for subscriptions.
  7. The moment you see any of the above in a code then that is a target rich environment for bad code.
  8. However bad, a code is, If it is in production then no one would touch it unless there is a requirement to change its functionality. And the rules of economy dont permit that as well but it shouldn't have been there in the first place So this code has been working fine doing automatic renewals of user services but now lets say we want to add auto renewals for some new products that have slightly different requirements or process flow.
  9. If you don't care about your code quality then what you are gonna do is bodge in another if / switch statement somewhere in the run method and job done. DBAD = Don't be a dick
  10. Number of time people say that they are refactoring but they are actually changing the code while adding new functionality which is a bit dangerous because you might introduce bugs while doing that. So hold on your new functionality and first refactor the code. The main ingredient of refactoring is to have unit and integration tests. If you already have them then go ahead changing test as well as code else first add the tests so you know when you break anything,
  11. Once I found some bad code that I thought needed refactoring. That code started doing something very simple about few months ago about showing different messages to users when a user request is complete. Sounds simple but it became a bit complicated after we added a background worker that will process the queues. Sometimes queues get held up due to some reason or the other. And then you need to show different messages to the users. So we passed different parameters to the redirected page and on the controller action of that redirected pages we ended up adding so many if / else statements to show different messages based on the presence of different parameters I was about to modify something and I saw that and said to myself F*UGLY. - discussed, lunch,back, got an idea, show n tell, discussed about the schedule, implemented
  12. So I refactored the code and one of my colleague also pitched in during final stages of refactoring that basically led to this,
  13. Should be small Named appropriately Do onlly one thing Should be at the same level of abstraction Should use minimum number of parameters