Preparing to write Clean Code
-
Upload
david-adsit -
Category
Technology
-
view
247 -
download
2
description
Transcript of Preparing to write Clean Code
![Page 1: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/1.jpg)
Preparing to write Clean Code
![Page 2: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/2.jpg)
The Clean Code Manifesto
![Page 3: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/3.jpg)
Preparing to writeClean Code
David Adsit@davidadsit
codeobsession.blogspot.com
![Page 4: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/4.jpg)
How to write Clean Code:
![Page 5: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/5.jpg)
How to write Clean Code:
Phase 1:Know what Clean
Code is
Phase 2:???
Phase 3:Profit!
![Page 6: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/6.jpg)
What is Clean Code?
![Page 7: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/7.jpg)
What is Clean Code?
![Page 8: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/8.jpg)
What is Clean Code?
![Page 9: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/9.jpg)
What is Clean Code?
“Clean code is simple and direct. Clean code reads like well-written prose. Clean code never obscures the designer’s intent but rather is full of crisp abstractions and straightforward lines of control.”
- Grady Booch
![Page 10: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/10.jpg)
What is Clean Code?
“With a ubiquitous language, conversations among developers, discussions among domain experts, and expressions in the code itself are all based on the same language, derived from a shared domain model.”
- Eric Evans
![Page 11: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/11.jpg)
What is Clean Code?
CleanCode
LegacyCode
![Page 12: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/12.jpg)
What is Legacy Code?“To me, legacy code is simply code without tests.…Code without tests is bad code. It doesn't matter how well written it is; it doesn't matter how pretty or object-oriented or well-encapsulated it is. With tests, we can change the behavior of our code quickly and verifiably.Without them, we really don't know if our code is getting better or worse.”
- Michael Feathers
![Page 13: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/13.jpg)
Attributes of Clean Code
Names of Classes and Methods should Reveal Intention
Comments should be rare and only used to explain why
![Page 14: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/14.jpg)
Attributes of Clean Code
Names of Classes and Methods should Reveal Intention
Comments should be rare and only used to explain why Formatting should be consistent
![Page 15: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/15.jpg)
Attributes of Clean Code
Names of Classes and Methods should Reveal Intention
Comments should be rare and only used to explain why Formatting should be consistent
Challenge: Create an editor that stores code as data in a canonical format and renders based on each developers’ preferences
![Page 16: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/16.jpg)
Attributes of Clean Code
Names of Classes and Methods should Reveal Intention
Comments should be rare and only used to explain why Formatting should be consistent
Challenge: Create an editor that stores code as data in a canonical format and renders based on each developers’ preferences
Classes and Methods should be small and focused The contents should not be surprising
![Page 17: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/17.jpg)
Attributes of Clean Code
Names of Classes and Methods should Reveal Intention
Comments should be rare and only used to explain why Formatting should be consistent
Challenge: Create an editor that stores code as data in a canonical format and renders based on each developers’ preferences
Classes and Methods should be small and focused The contents should not be surprising
Classes should have and express a clear role Object != Value Type != Service != Data Transfer Object/View
Model
![Page 18: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/18.jpg)
Attributes of Clean Code
Names of Classes and Methods should Reveal Intention
Comments should be rare and only used to explain why Formatting should be consistent
Challenge: Create an editor that stores code as data in a canonical format and renders based on each developers’ preferences
Classes and Methods should be small and focused The contents should not be surprising
Classes should have and express a clear role Object != Value Type != Service != Data Transfer Object/View
Model Boundaries should be clear
Reuse/3rd party libraries can be great! Protect your code with adapters
![Page 19: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/19.jpg)
Attributes of Clean Code
TESTED!
![Page 20: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/20.jpg)
The Full Test Suite
![Page 21: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/21.jpg)
The Full Test Suite
Unit Tests
Integration Tests
Acceptance Tests
UI Tests
![Page 22: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/22.jpg)
The Full Test Suite
Unit Tests
Integration Tests
Acceptance Tests
UI Tests
![Page 23: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/23.jpg)
The Full Test Suite
Unit Tests
Integration Tests
Acceptance Tests
UI Tests
![Page 24: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/24.jpg)
The Full Test Suite
Unit Tests
Integration Tests
Acceptance Tests
UI Tests
![Page 25: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/25.jpg)
That all sounds great but…
![Page 26: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/26.jpg)
That all sounds great but…
![Page 27: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/27.jpg)
That all sounds great but…
![Page 28: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/28.jpg)
That all sounds great but…
The Boy Scout Rule (for Code)
Leave the code cleaner than you found it.
![Page 29: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/29.jpg)
How to write Clean Code:
Phase 1:Know what
Clean Code is
Phase 2:Continuous
Improvement
Phase 3:Profit!
![Page 30: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/30.jpg)
The Long Road
“How long will it take to master aikido?” a prospective student asks. “How long do you expect to live?” is the only respectable response.
- George LeonardMastery
![Page 31: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/31.jpg)
The Long Road
“To become truly good at programming is a life’s work, an ongoing enterprise of learning and practicing.”
- Ron Jeffries et al. Extreme Programming Installed
![Page 32: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/32.jpg)
Kindred Spirits
![Page 33: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/33.jpg)
Utah Software Craftsmanship Group
We meet on the first Wednesday of each month from 6pm to 8pm at:
Neumont UniversityRoom 300
10701 S. Riverfront ParkwaySouth Jordan, Utah 84095
https://groups.google.com/forum/?fromgroups#!forum/ut-software-craftsmanship
( http://bit.ly/utahsc )
![Page 34: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/34.jpg)
The Utah SC Group Meeting
Lightning talks 1-3 / month 5-7 minutes max
![Page 35: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/35.jpg)
The Utah SC Group Meeting
Lightning talks 1-3 / month 5-7 minutes max
Discussion Large or small groups
![Page 36: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/36.jpg)
The Utah SC Group Meeting
Lightning talks 1-3 / month 5-7 minutes max
Discussion Large or small groups
Coding exercise Katas Randori Experiments Language demos
![Page 37: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/37.jpg)
The Utah SC Group Meeting
Lightning talks 1-3 / month 5-7 minutes max
Discussion Large or small groups
Coding exercise Katas Randori Experiments Language demos
Pie!
![Page 38: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/38.jpg)
As Seen on TV!!
![Page 39: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/39.jpg)
Software Craftsmanship Manifesto
As aspiring Software Craftsmen we are raising the bar of professional software development by practicing it and helping others learn the craft. Through this work we have come to value:
Not only working software, but also well-crafted software Not only responding to change, but also steadily adding val
ue Not only individuals and interactions, but also a communit
y of professionals Not only customer collaboration, but also productive/
partnerships
That is, in pursuit of the items on the left, we have found the items on the right to be indispensable.
![Page 40: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/40.jpg)
Professionalism
Responsibility Do no harm to function Do no harm to structure
![Page 41: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/41.jpg)
Professionalism
Responsibility Do no harm to function Do no harm to structure
Honesty Yes No Estimates
![Page 42: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/42.jpg)
Professionalism
Responsibility Do no harm to function Do no harm to structure
Honesty Yes No Estimates
Readiness Study Practice
![Page 43: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/43.jpg)
Professionalism
Responsibility Do no harm to function Do no harm to structure
Honesty Yes No Estimates
Readiness Study Practice
Mentorship Find a mentor Be a mentor
![Page 44: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/44.jpg)
3 Great Virtues
"We will encourage you to develop the three great virtues of a programmer: laziness, impatience, and hubris.“
- Larry Wall
![Page 45: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/45.jpg)
Laziness
The quality that makes you go to great effort to reduce overall energy expenditure. It makes you write labor-saving programs that other people will find useful, and document what you wrote so you don't have to answer so many questions about it. Hence, the first great virtue of a programmer.
![Page 46: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/46.jpg)
Impatience
The anger you feel when the computer is being lazy. This makes you write programs that don't just react to your needs, but actually anticipate them. Or at least pretend to. Hence, the second great virtue of a programmer.
![Page 47: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/47.jpg)
Hubris
Excessive pride, the sort of thing Zeus zaps you for. Also the quality that makes you write (and maintain) programs that other people won't want to say bad things about. Hence, the third great virtue of a programmer.
![Page 48: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/48.jpg)
Make the Computer do the Work
Use source control There’s no excuse not to
![Page 49: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/49.jpg)
Make the Computer do the Work
Use source control There’s no excuse not to
Get a refactoring tool Computers are better at mundane, repetitive tasks than people
are
![Page 50: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/50.jpg)
Make the Computer do the Work
Use source control There’s no excuse not to
Get a refactoring tool Computers are better at mundane, repetitive tasks than people
are Eliminate manual build steps
Don’t forget the database
![Page 51: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/51.jpg)
Make the Computer do the Work
Use source control There’s no excuse not to
Get a refactoring tool Computers are better at mundane, repetitive tasks than people
are Eliminate manual build steps
Don’t forget the database Automate the verification process
![Page 52: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/52.jpg)
Make the Computer do the Work
Use source control There’s no excuse not to
Get a refactoring tool Computers are better at mundane, repetitive tasks than people
are Eliminate manual build steps
Don’t forget the database Automate the verification process Push-button deployment / rollback
![Page 53: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/53.jpg)
Teamwork
![Page 54: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/54.jpg)
Strengthen Your Team
Start Pair Programming The most efficient way to improve the code is to test it The most efficient way to improve a team is to pair
![Page 55: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/55.jpg)
Strengthen Your Team
Start Pair Programming The most efficient way to improve the code is to test it The most efficient way to improve a team is to pair
Start a study group at work Read a chapter from a relevant book and discuss it
![Page 56: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/56.jpg)
Strengthen Your Team
Start Pair Programming The most efficient way to improve the code is to test it The most efficient way to improve a team is to pair
Start a study group at work Read a chapter from a relevant book and discuss it
Go to a conference Share what you learned
![Page 57: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/57.jpg)
Strengthen Your Team
Start Pair Programming The most efficient way to improve the code is to test it The most efficient way to improve a team is to pair
Start a study group at work Read a chapter from a relevant book and discuss it
Go to a conference Share what you learned
Find a user group Attend monthly
![Page 58: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/58.jpg)
Strengthen Your Team
Start Pair Programming The most efficient way to improve the code is to test it The most efficient way to improve a team is to pair
Start a study group at work Read a chapter from a relevant book and discuss it
Go to a conference Share what you learned
Find a user group Attend monthly
Follow interesting developers online Google Reader is dead, but blogs aren’t and neither is Twitter
![Page 59: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/59.jpg)
Strengthen Your Team
Start Pair Programming The most efficient way to improve the code is to test it The most efficient way to improve a team is to pair
Start a study group at work Read a chapter from a relevant book and discuss it
Go to a conference Share what you learned
Find a user group Attend monthly
Follow interesting developers online Google Reader is dead, but blogs aren’t and neither is Twitter
Create your own reading list Some concepts are too big for a blog post and require a book
to explore The more you know, the more you can share with your team
![Page 60: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/60.jpg)
How to write Clean Code:
Phase 1:Know what
Clean Code is
Phase 2:Continuous
Improvement
Phase 3:Profit!
![Page 61: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/61.jpg)
Visit the sponsors
Don’t forget rate the speakers very highly!
![Page 62: Preparing to write Clean Code](https://reader036.fdocuments.in/reader036/viewer/2022062419/558972e8d8b42ab74a8b4586/html5/thumbnails/62.jpg)
Questions?
David Adsit@davidadsit
codeobsession.blogspot.com