SlideShare une entreprise Scribd logo
1  sur  17
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

Contenu connexe

Tendances

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
 

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

En vedette

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
 

En vedette (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
 

Similaire à 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
 

Similaire à 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
 

Dernier

Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
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.pptxHampshireHUG
 
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 SolutionsEnterprise Knowledge
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
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
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
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
 
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 WorkerThousandEyes
 
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 Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
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
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
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 slidevu2urc
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 

Dernier (20)

Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
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
 
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
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
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...
 
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
 
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 Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.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
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 

Code sense

Notes de l'éditeur

  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