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

Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
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
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
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
 

Recently uploaded (20)

Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
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
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
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
 

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/)