SlideShare a Scribd company logo
1 of 24
Write Code For
The Future You
Paul Gower
@paulmgower
Full Disclosure…
u First Internship writing Perl script, summer 2000
u Obfuscated Perl Contest
u Annual competition between 1996 and 2000
u Entries were judged on incomprehensibility among other
things
u Mentality was to write “elite code” that was hard to
understand
Story Time
u First job out of college, 2001
u Alltel Client/Server University
u 6 month training class
u Textbook: Code Complete
u 8a to 5p every day
u Lecture
u Lab
u Code Reviews
Story Time
u Added to project towards end of
development
u Fixing bugs in code you didn’t write
u The Mythical Man Month by Fred Brooks
Why Worry about Maintenance?
Creating  Code
30%
Maintaining  Code
70%
Why Write Code for Reader?
Writing Code
10%
Reading Code
90%
Why Write Code for Reader?
u Sept 1991, Comp.lang.c++ newsgroup discussion
u Why not use comma more?
u Like this:
if (condition)
var = value, anothervar = anothervalue;
u However consider this:
if (condition)
var = value; anothervar = anothervalue;
Food for thought
“Always code as if the guy who
ends up maintaining your code
will be a violent psychopath who
knows where you live”
John F. Woods
Writing Better Code
u Code Complete published in 1993, 2004
u Agile Manifesto signed 2001
u Clean Code book published in 2009
Power in Variable Names
u Describe the entity it represents
u Easy to understand and read
u Be specific as possible
Variable Name Examples
Bad Names
u total, ct, checks, CHKTTL
u velt, tv, train
u cd, current, c, date
u lpp, lines
Good Names
u runningTotal, checkTotal
u trainVelocity, velocityInMph
u currentDate, todaysDate
u linesPerPage
Ban Magic Numbers
u Don’t use magic numbers
u Instead use constants or enums
u Makes code more readable / self
documenting
Bad Magic Number
public void setPassword(String password) {
// don't do this
if (password.length() > 7) {
throw new InvalidArgumentException("password");
}
}
Use Constants
public void setPassword(String password) {
const int MAX_PASSWORD_SIZE = 7;
if (password.length() > MAX_PASSWORD_SIZE) {
throw new InvalidArgumentException("password");
}
}
Don’t Repeat Yourself (DRY)
u Duplication leads to maintenance issues
u Y2K Culprit?
“Every piece of knowledge must have a
single, unabiguous, authoritative
representation within a system”
Classes: Do One Thing Well
u Each responsibility is an axis of
change
u Change is going to happen
u Loose Coupling
More than 1 Responsibility
Single Responsibility
Stop Writing Legacy Code
u Legacy Code = Code without Tests
u Great Step-by-step guide
u Write Unit Test as you use legacy
methods
Code Reviews
u Should involve the programmer and at
least 2 reviewers.
u Using “peer pressure”
u Encourages collaboration
Code Reviews Tips
u Keep a positive attitude
u Check your ego
u Review all code
u Code Review early and often
Final Review
u Give better variable names
u Don’t use magic numbers
u Keep your code DRY
u Classes should do one thing
u Write Unit Tests
u Have regular Code Reviews
Questions?
Paul Gower
@paulmgower
http://lunamark.com
Resources
u The Mythical Man Month by Frederick P. Brooks Jr
(http://www.amazon.com/The-Mythical-Man-Month-Engineering-
Anniversary/dp/0201835959)
u Code Complete by Steve McConnell
(http://www.amazon.com/Code-Complete-Practical-Handbook-
Construction/dp/0735619670)
u Clean Code by Robert C. Martin (http://www.amazon.com/Clean-
Code-Handbook-Software-Craftsmanship/dp/0132350882)
u Working Effectively with Legacy Code by Michael Feathers
(http://www.amazon.com/Working-Effectively-Legacy-Michael-
Feathers/dp/0131177052)
u FogCreek Software Blog
u Effective Code Reviews - 9 Tips from a Converted Skeptic
(http://blog.fogcreek.com/effective-code-reviews-9-tips-from-a-
converted-skeptic/)
u Stop More Bugs with our Code Review Checklist
(http://blog.fogcreek.com/increase-defect-detection-with-our-code-
review-checklist-example/)

More Related Content

Viewers also liked

2016 Federal User Group Conference - What's New in TeamForge
2016 Federal User Group Conference - What's New in TeamForge2016 Federal User Group Conference - What's New in TeamForge
2016 Federal User Group Conference - What's New in TeamForgeCollabNet
 
แผนการจัดการเรียนรู้ที่ 5
แผนการจัดการเรียนรู้ที่ 5แผนการจัดการเรียนรู้ที่ 5
แผนการจัดการเรียนรู้ที่ 5Meaw Sukee
 
Farmacogenomica de reacciones de hipersensibilidad inducidas por medicamentos
Farmacogenomica de reacciones de hipersensibilidad inducidas por medicamentosFarmacogenomica de reacciones de hipersensibilidad inducidas por medicamentos
Farmacogenomica de reacciones de hipersensibilidad inducidas por medicamentosJESSICA LYONS
 
Dictionnaire de mathématiques
Dictionnaire de mathématiquesDictionnaire de mathématiques
Dictionnaire de mathématiquessalah fenni
 
SIIE 2016. Proyecto eMadrid: Metodologías Educativas, Ludificación y Calidad....
SIIE 2016. Proyecto eMadrid: Metodologías Educativas, Ludificación y Calidad....SIIE 2016. Proyecto eMadrid: Metodologías Educativas, Ludificación y Calidad....
SIIE 2016. Proyecto eMadrid: Metodologías Educativas, Ludificación y Calidad....eMadrid network
 
Producción de fármacos por ingeniería genética
Producción de fármacos por ingeniería genéticaProducción de fármacos por ingeniería genética
Producción de fármacos por ingeniería genéticabiogeoma
 

Viewers also liked (10)

2016 Federal User Group Conference - What's New in TeamForge
2016 Federal User Group Conference - What's New in TeamForge2016 Federal User Group Conference - What's New in TeamForge
2016 Federal User Group Conference - What's New in TeamForge
 
Deber 2 s.o
Deber 2 s.oDeber 2 s.o
Deber 2 s.o
 
แผนการจัดการเรียนรู้ที่ 5
แผนการจัดการเรียนรู้ที่ 5แผนการจัดการเรียนรู้ที่ 5
แผนการจัดการเรียนรู้ที่ 5
 
Farmacogenomica de reacciones de hipersensibilidad inducidas por medicamentos
Farmacogenomica de reacciones de hipersensibilidad inducidas por medicamentosFarmacogenomica de reacciones de hipersensibilidad inducidas por medicamentos
Farmacogenomica de reacciones de hipersensibilidad inducidas por medicamentos
 
Aula hipertensão
Aula hipertensãoAula hipertensão
Aula hipertensão
 
Analiza swot
Analiza swotAnaliza swot
Analiza swot
 
Primjer Content Marketing Plana 2016
Primjer Content Marketing Plana 2016Primjer Content Marketing Plana 2016
Primjer Content Marketing Plana 2016
 
Dictionnaire de mathématiques
Dictionnaire de mathématiquesDictionnaire de mathématiques
Dictionnaire de mathématiques
 
SIIE 2016. Proyecto eMadrid: Metodologías Educativas, Ludificación y Calidad....
SIIE 2016. Proyecto eMadrid: Metodologías Educativas, Ludificación y Calidad....SIIE 2016. Proyecto eMadrid: Metodologías Educativas, Ludificación y Calidad....
SIIE 2016. Proyecto eMadrid: Metodologías Educativas, Ludificación y Calidad....
 
Producción de fármacos por ingeniería genética
Producción de fármacos por ingeniería genéticaProducción de fármacos por ingeniería genética
Producción de fármacos por ingeniería genética
 

Similar to Write Code For The Future You - LR Tech Fest

TDD — Are you sure you properly test code?
TDD — Are you sure you properly test code?TDD — Are you sure you properly test code?
TDD — Are you sure you properly test code?Dmitriy Nesteryuk
 
Upwork time log and difficulty 20160523
Upwork time log and difficulty 20160523Upwork time log and difficulty 20160523
Upwork time log and difficulty 20160523Sharon Liu
 
Grails Worst Practices
Grails Worst PracticesGrails Worst Practices
Grails Worst PracticesBurt Beckwith
 
[Php vigo][talk] unit testing sucks ( and it's your fault )
[Php vigo][talk] unit testing sucks ( and it's your fault )[Php vigo][talk] unit testing sucks ( and it's your fault )
[Php vigo][talk] unit testing sucks ( and it's your fault )PHP Vigo
 
Javascript breakdown-workbook
Javascript breakdown-workbookJavascript breakdown-workbook
Javascript breakdown-workbookHARUN PEHLIVAN
 
Expressive Testing ...and your Code For Free?
Expressive Testing ...and your Code For Free?Expressive Testing ...and your Code For Free?
Expressive Testing ...and your Code For Free?ESUG
 
Cis 1403 lab1- the process of programming
Cis 1403 lab1- the process of programmingCis 1403 lab1- the process of programming
Cis 1403 lab1- the process of programmingHamad Odhabi
 
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in FlexassertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flexmichael.labriola
 
Test Presentation
Test PresentationTest Presentation
Test Presentationsetitesuk
 
Art of unit testing: how to do it right
Art of unit testing: how to do it rightArt of unit testing: how to do it right
Art of unit testing: how to do it rightDmytro Patserkovskyi
 
N E T Coding Best Practices
N E T  Coding  Best  PracticesN E T  Coding  Best  Practices
N E T Coding Best PracticesAbhishek Desai
 
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
 
[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
 
Advanced java script essentials v1
Advanced java script essentials v1Advanced java script essentials v1
Advanced java script essentials v1ASHUTOSHPATKAR1
 
13 javascript techniques to improve your code
13 javascript techniques to improve your code13 javascript techniques to improve your code
13 javascript techniques to improve your codeSurendra kumar
 
Design Patterns
Design PatternsDesign Patterns
Design PatternsRaquel Pau
 
Python breakdown-workbook
Python breakdown-workbookPython breakdown-workbook
Python breakdown-workbookHARUN PEHLIVAN
 

Similar to Write Code For The Future You - LR Tech Fest (20)

Good Coding Practices with JavaScript
Good Coding Practices with JavaScriptGood Coding Practices with JavaScript
Good Coding Practices with JavaScript
 
TDD — Are you sure you properly test code?
TDD — Are you sure you properly test code?TDD — Are you sure you properly test code?
TDD — Are you sure you properly test code?
 
Upwork time log and difficulty 20160523
Upwork time log and difficulty 20160523Upwork time log and difficulty 20160523
Upwork time log and difficulty 20160523
 
Grails Worst Practices
Grails Worst PracticesGrails Worst Practices
Grails Worst Practices
 
[Php vigo][talk] unit testing sucks ( and it's your fault )
[Php vigo][talk] unit testing sucks ( and it's your fault )[Php vigo][talk] unit testing sucks ( and it's your fault )
[Php vigo][talk] unit testing sucks ( and it's your fault )
 
Javascript breakdown-workbook
Javascript breakdown-workbookJavascript breakdown-workbook
Javascript breakdown-workbook
 
Expressive Testing ...and your Code For Free?
Expressive Testing ...and your Code For Free?Expressive Testing ...and your Code For Free?
Expressive Testing ...and your Code For Free?
 
Cis 1403 lab1- the process of programming
Cis 1403 lab1- the process of programmingCis 1403 lab1- the process of programming
Cis 1403 lab1- the process of programming
 
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in FlexassertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
 
Test Presentation
Test PresentationTest Presentation
Test Presentation
 
Coding standards
Coding standardsCoding standards
Coding standards
 
Class 9 Lecture Notes
Class 9 Lecture NotesClass 9 Lecture Notes
Class 9 Lecture Notes
 
Art of unit testing: how to do it right
Art of unit testing: how to do it rightArt of unit testing: how to do it right
Art of unit testing: how to do it right
 
N E T Coding Best Practices
N E T  Coding  Best  PracticesN E T  Coding  Best  Practices
N E T Coding Best Practices
 
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...
 
[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,...
 
Advanced java script essentials v1
Advanced java script essentials v1Advanced java script essentials v1
Advanced java script essentials v1
 
13 javascript techniques to improve your code
13 javascript techniques to improve your code13 javascript techniques to improve your code
13 javascript techniques to improve your code
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Python breakdown-workbook
Python breakdown-workbookPython breakdown-workbook
Python breakdown-workbook
 

More from Paul Gower

Be a Better Remote Agile Team Member
Be a Better Remote Agile Team MemberBe a Better Remote Agile Team Member
Be a Better Remote Agile Team MemberPaul Gower
 
Overcoming Delay: How The Best Developers Increase Productivity
Overcoming Delay: How The Best Developers Increase ProductivityOvercoming Delay: How The Best Developers Increase Productivity
Overcoming Delay: How The Best Developers Increase ProductivityPaul Gower
 
Codestock 2019 - Build a successful remote agile team in three easy steps!
Codestock 2019 - Build a successful remote agile team in three easy steps!Codestock 2019 - Build a successful remote agile team in three easy steps!
Codestock 2019 - Build a successful remote agile team in three easy steps!Paul Gower
 
WeRockIT 2019 - Build a successful remote agile team in three easy steps!
WeRockIT 2019 - Build a successful remote agile team in three easy steps!WeRockIT 2019 - Build a successful remote agile team in three easy steps!
WeRockIT 2019 - Build a successful remote agile team in three easy steps!Paul Gower
 
Overcoming Delay: How The Best Developers Increase Productivity
Overcoming Delay: How The Best Developers Increase ProductivityOvercoming Delay: How The Best Developers Increase Productivity
Overcoming Delay: How The Best Developers Increase ProductivityPaul Gower
 
Rub Some DevOps on your NodeJS app in Azure - ScenicCitySummit 2018
Rub Some DevOps on your NodeJS app in Azure - ScenicCitySummit 2018Rub Some DevOps on your NodeJS app in Azure - ScenicCitySummit 2018
Rub Some DevOps on your NodeJS app in Azure - ScenicCitySummit 2018Paul Gower
 
Unit Testing in Umbraco
Unit Testing in UmbracoUnit Testing in Umbraco
Unit Testing in UmbracoPaul Gower
 
Code Review: How and When
Code Review: How and WhenCode Review: How and When
Code Review: How and WhenPaul Gower
 
Code Review: How and When
Code Review: How and WhenCode Review: How and When
Code Review: How and WhenPaul Gower
 
Code Review: How And When
Code Review: How And WhenCode Review: How And When
Code Review: How And WhenPaul Gower
 
Code Review: How and When - Tulsa TechFest 2016
Code Review: How and When - Tulsa TechFest 2016Code Review: How and When - Tulsa TechFest 2016
Code Review: How and When - Tulsa TechFest 2016Paul Gower
 
Write Code For The Future You - Tulsa TechFest 2016
Write Code For The Future You - Tulsa TechFest 2016Write Code For The Future You - Tulsa TechFest 2016
Write Code For The Future You - Tulsa TechFest 2016Paul Gower
 
How and When To Code Review
How and When To Code ReviewHow and When To Code Review
How and When To Code ReviewPaul Gower
 
Windows 8 and Phone App Development
Windows 8 and Phone App DevelopmentWindows 8 and Phone App Development
Windows 8 and Phone App DevelopmentPaul Gower
 

More from Paul Gower (15)

Be a Better Remote Agile Team Member
Be a Better Remote Agile Team MemberBe a Better Remote Agile Team Member
Be a Better Remote Agile Team Member
 
Overcoming Delay: How The Best Developers Increase Productivity
Overcoming Delay: How The Best Developers Increase ProductivityOvercoming Delay: How The Best Developers Increase Productivity
Overcoming Delay: How The Best Developers Increase Productivity
 
Codestock 2019 - Build a successful remote agile team in three easy steps!
Codestock 2019 - Build a successful remote agile team in three easy steps!Codestock 2019 - Build a successful remote agile team in three easy steps!
Codestock 2019 - Build a successful remote agile team in three easy steps!
 
WeRockIT 2019 - Build a successful remote agile team in three easy steps!
WeRockIT 2019 - Build a successful remote agile team in three easy steps!WeRockIT 2019 - Build a successful remote agile team in three easy steps!
WeRockIT 2019 - Build a successful remote agile team in three easy steps!
 
Overcoming Delay: How The Best Developers Increase Productivity
Overcoming Delay: How The Best Developers Increase ProductivityOvercoming Delay: How The Best Developers Increase Productivity
Overcoming Delay: How The Best Developers Increase Productivity
 
Rub Some DevOps on your NodeJS app in Azure - ScenicCitySummit 2018
Rub Some DevOps on your NodeJS app in Azure - ScenicCitySummit 2018Rub Some DevOps on your NodeJS app in Azure - ScenicCitySummit 2018
Rub Some DevOps on your NodeJS app in Azure - ScenicCitySummit 2018
 
Unit Testing in Umbraco
Unit Testing in UmbracoUnit Testing in Umbraco
Unit Testing in Umbraco
 
Code Review: How and When
Code Review: How and WhenCode Review: How and When
Code Review: How and When
 
Code Review: How and When
Code Review: How and WhenCode Review: How and When
Code Review: How and When
 
Code Review: How And When
Code Review: How And WhenCode Review: How And When
Code Review: How And When
 
Code Review: How and When - Tulsa TechFest 2016
Code Review: How and When - Tulsa TechFest 2016Code Review: How and When - Tulsa TechFest 2016
Code Review: How and When - Tulsa TechFest 2016
 
Write Code For The Future You - Tulsa TechFest 2016
Write Code For The Future You - Tulsa TechFest 2016Write Code For The Future You - Tulsa TechFest 2016
Write Code For The Future You - Tulsa TechFest 2016
 
How and When To Code Review
How and When To Code ReviewHow and When To Code Review
How and When To Code Review
 
Windows 8 and Phone App Development
Windows 8 and Phone App DevelopmentWindows 8 and Phone App Development
Windows 8 and Phone App Development
 
Code Kata
Code KataCode Kata
Code Kata
 

Recently uploaded

8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...kalichargn70th171
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 

Recently uploaded (20)

8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 

Write Code For The Future You - LR Tech Fest

  • 1. Write Code For The Future You Paul Gower @paulmgower
  • 2. Full Disclosure… u First Internship writing Perl script, summer 2000 u Obfuscated Perl Contest u Annual competition between 1996 and 2000 u Entries were judged on incomprehensibility among other things u Mentality was to write “elite code” that was hard to understand
  • 3. Story Time u First job out of college, 2001 u Alltel Client/Server University u 6 month training class u Textbook: Code Complete u 8a to 5p every day u Lecture u Lab u Code Reviews
  • 4. Story Time u Added to project towards end of development u Fixing bugs in code you didn’t write u The Mythical Man Month by Fred Brooks
  • 5. Why Worry about Maintenance? Creating  Code 30% Maintaining  Code 70%
  • 6. Why Write Code for Reader? Writing Code 10% Reading Code 90%
  • 7. Why Write Code for Reader? u Sept 1991, Comp.lang.c++ newsgroup discussion u Why not use comma more? u Like this: if (condition) var = value, anothervar = anothervalue; u However consider this: if (condition) var = value; anothervar = anothervalue;
  • 8. Food for thought “Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live” John F. Woods
  • 9. Writing Better Code u Code Complete published in 1993, 2004 u Agile Manifesto signed 2001 u Clean Code book published in 2009
  • 10. Power in Variable Names u Describe the entity it represents u Easy to understand and read u Be specific as possible
  • 11. Variable Name Examples Bad Names u total, ct, checks, CHKTTL u velt, tv, train u cd, current, c, date u lpp, lines Good Names u runningTotal, checkTotal u trainVelocity, velocityInMph u currentDate, todaysDate u linesPerPage
  • 12. Ban Magic Numbers u Don’t use magic numbers u Instead use constants or enums u Makes code more readable / self documenting
  • 13. Bad Magic Number public void setPassword(String password) { // don't do this if (password.length() > 7) { throw new InvalidArgumentException("password"); } }
  • 14. Use Constants public void setPassword(String password) { const int MAX_PASSWORD_SIZE = 7; if (password.length() > MAX_PASSWORD_SIZE) { throw new InvalidArgumentException("password"); } }
  • 15. Don’t Repeat Yourself (DRY) u Duplication leads to maintenance issues u Y2K Culprit? “Every piece of knowledge must have a single, unabiguous, authoritative representation within a system”
  • 16. Classes: Do One Thing Well u Each responsibility is an axis of change u Change is going to happen u Loose Coupling
  • 17. More than 1 Responsibility
  • 19. Stop Writing Legacy Code u Legacy Code = Code without Tests u Great Step-by-step guide u Write Unit Test as you use legacy methods
  • 20. Code Reviews u Should involve the programmer and at least 2 reviewers. u Using “peer pressure” u Encourages collaboration
  • 21. Code Reviews Tips u Keep a positive attitude u Check your ego u Review all code u Code Review early and often
  • 22. Final Review u Give better variable names u Don’t use magic numbers u Keep your code DRY u Classes should do one thing u Write Unit Tests u Have regular Code Reviews
  • 24. Resources u The Mythical Man Month by Frederick P. Brooks Jr (http://www.amazon.com/The-Mythical-Man-Month-Engineering- Anniversary/dp/0201835959) u Code Complete by Steve McConnell (http://www.amazon.com/Code-Complete-Practical-Handbook- Construction/dp/0735619670) u Clean Code by Robert C. Martin (http://www.amazon.com/Clean- Code-Handbook-Software-Craftsmanship/dp/0132350882) u Working Effectively with Legacy Code by Michael Feathers (http://www.amazon.com/Working-Effectively-Legacy-Michael- Feathers/dp/0131177052) u FogCreek Software Blog u Effective Code Reviews - 9 Tips from a Converted Skeptic (http://blog.fogcreek.com/effective-code-reviews-9-tips-from-a- converted-skeptic/) u Stop More Bugs with our Code Review Checklist (http://blog.fogcreek.com/increase-defect-detection-with-our-code- review-checklist-example/)