code style guides - university of wisconsin–madison€¦ · code style guides or: how i learned...
TRANSCRIPT
![Page 1: Code Style Guides - University of Wisconsin–Madison€¦ · Code Style Guides Or: How I Learned to Stop Worrying and Love Spaces](https://reader035.vdocuments.site/reader035/viewer/2022070113/6059c340d48e7a4df96951b3/html5/thumbnails/1.jpg)
Code Style GuidesOr: How I Learned to Stop Worrying and Love Spaces
![Page 2: Code Style Guides - University of Wisconsin–Madison€¦ · Code Style Guides Or: How I Learned to Stop Worrying and Love Spaces](https://reader035.vdocuments.site/reader035/viewer/2022070113/6059c340d48e7a4df96951b3/html5/thumbnails/2.jpg)
Who?● David M Sibley
● New MyUW Full Stack Developer
● Previous 7 years at US Geological Survey
● As Technical Lead, I had many opinions
● Coming in to MyUW, I decided to shove those to the back and learn
![Page 3: Code Style Guides - University of Wisconsin–Madison€¦ · Code Style Guides Or: How I Learned to Stop Worrying and Love Spaces](https://reader035.vdocuments.site/reader035/viewer/2022070113/6059c340d48e7a4df96951b3/html5/thumbnails/3.jpg)
Tabs vs Spaces
![Page 4: Code Style Guides - University of Wisconsin–Madison€¦ · Code Style Guides Or: How I Learned to Stop Worrying and Love Spaces](https://reader035.vdocuments.site/reader035/viewer/2022070113/6059c340d48e7a4df96951b3/html5/thumbnails/4.jpg)
MyUW Values● Open Source
● Small Directed
Commits
● Pull Request
Review
![Page 5: Code Style Guides - University of Wisconsin–Madison€¦ · Code Style Guides Or: How I Learned to Stop Worrying and Love Spaces](https://reader035.vdocuments.site/reader035/viewer/2022070113/6059c340d48e7a4df96951b3/html5/thumbnails/5.jpg)
Which fights are worth it?● As Technical Lead, I had many opinions
○ Tabs
○ No extraneous commas
○ One return statement
○ Semicolons at the end of every statement
● Coming in to MyUW, I decided to shove those to the back and learn
○ There is no one true way to write code
![Page 6: Code Style Guides - University of Wisconsin–Madison€¦ · Code Style Guides Or: How I Learned to Stop Worrying and Love Spaces](https://reader035.vdocuments.site/reader035/viewer/2022070113/6059c340d48e7a4df96951b3/html5/thumbnails/6.jpg)
What is going on here?● You don’t want to scroll through a thousand line diff for a fifty line change
![Page 7: Code Style Guides - University of Wisconsin–Madison€¦ · Code Style Guides Or: How I Learned to Stop Worrying and Love Spaces](https://reader035.vdocuments.site/reader035/viewer/2022070113/6059c340d48e7a4df96951b3/html5/thumbnails/7.jpg)
The Crux
Style differences are the bottleneck for productivity of a team.
Not style merits
![Page 8: Code Style Guides - University of Wisconsin–Madison€¦ · Code Style Guides Or: How I Learned to Stop Worrying and Love Spaces](https://reader035.vdocuments.site/reader035/viewer/2022070113/6059c340d48e7a4df96951b3/html5/thumbnails/8.jpg)
MyUW Plan● Arbitrarily pick ONE overarching style
● Give team members the tools to succeed
![Page 9: Code Style Guides - University of Wisconsin–Madison€¦ · Code Style Guides Or: How I Learned to Stop Worrying and Love Spaces](https://reader035.vdocuments.site/reader035/viewer/2022070113/6059c340d48e7a4df96951b3/html5/thumbnails/9.jpg)
MyUW Implementation● Google Style for Javascript
● ESLint
○ Husky Plugin to Lint on Commit
![Page 10: Code Style Guides - University of Wisconsin–Madison€¦ · Code Style Guides Or: How I Learned to Stop Worrying and Love Spaces](https://reader035.vdocuments.site/reader035/viewer/2022070113/6059c340d48e7a4df96951b3/html5/thumbnails/10.jpg)
Google Style● There’s a lot of
rules!
● Let someone
else figure this
out.
![Page 11: Code Style Guides - University of Wisconsin–Madison€¦ · Code Style Guides Or: How I Learned to Stop Worrying and Love Spaces](https://reader035.vdocuments.site/reader035/viewer/2022070113/6059c340d48e7a4df96951b3/html5/thumbnails/11.jpg)
Google Style● I don’t want to
look through
this every time
I write code.
![Page 12: Code Style Guides - University of Wisconsin–Madison€¦ · Code Style Guides Or: How I Learned to Stop Worrying and Love Spaces](https://reader035.vdocuments.site/reader035/viewer/2022070113/6059c340d48e7a4df96951b3/html5/thumbnails/12.jpg)
ESLint● Automated
Style Checking
![Page 13: Code Style Guides - University of Wisconsin–Madison€¦ · Code Style Guides Or: How I Learned to Stop Worrying and Love Spaces](https://reader035.vdocuments.site/reader035/viewer/2022070113/6059c340d48e7a4df96951b3/html5/thumbnails/13.jpg)
Google Style● Two Spaces per Indentation
● Don’t Pad Functions with Whitespace
● Trailing & Extraneous Commas
● 80 Characters per Line
![Page 14: Code Style Guides - University of Wisconsin–Madison€¦ · Code Style Guides Or: How I Learned to Stop Worrying and Love Spaces](https://reader035.vdocuments.site/reader035/viewer/2022070113/6059c340d48e7a4df96951b3/html5/thumbnails/14.jpg)
ESLint● 2925 ERRORS?!
![Page 15: Code Style Guides - University of Wisconsin–Madison€¦ · Code Style Guides Or: How I Learned to Stop Worrying and Love Spaces](https://reader035.vdocuments.site/reader035/viewer/2022070113/6059c340d48e7a4df96951b3/html5/thumbnails/15.jpg)
ESLint● Run Autofix
● Warn down large
scale offenses
● Left with ~300
miscellaneous
errors
○ Over 20 files? I
can handle that.
![Page 16: Code Style Guides - University of Wisconsin–Madison€¦ · Code Style Guides Or: How I Learned to Stop Worrying and Love Spaces](https://reader035.vdocuments.site/reader035/viewer/2022070113/6059c340d48e7a4df96951b3/html5/thumbnails/16.jpg)
ESLint● Add rules back in
one by one until
you’re adhering
to the standard
![Page 17: Code Style Guides - University of Wisconsin–Madison€¦ · Code Style Guides Or: How I Learned to Stop Worrying and Love Spaces](https://reader035.vdocuments.site/reader035/viewer/2022070113/6059c340d48e7a4df96951b3/html5/thumbnails/17.jpg)
ESLint● Add rules back in
one by one until
you’re adhering
to the standard
![Page 18: Code Style Guides - University of Wisconsin–Madison€¦ · Code Style Guides Or: How I Learned to Stop Worrying and Love Spaces](https://reader035.vdocuments.site/reader035/viewer/2022070113/6059c340d48e7a4df96951b3/html5/thumbnails/18.jpg)
ESLint● Add rules back in
one by one until
you’re adhering
to the standard
![Page 19: Code Style Guides - University of Wisconsin–Madison€¦ · Code Style Guides Or: How I Learned to Stop Worrying and Love Spaces](https://reader035.vdocuments.site/reader035/viewer/2022070113/6059c340d48e7a4df96951b3/html5/thumbnails/19.jpg)
Lessons Learned● Commit by Rule, not Structure
● Don’t make exceptions, unless style would change
functionality.
● Save Line Length for last.
![Page 20: Code Style Guides - University of Wisconsin–Madison€¦ · Code Style Guides Or: How I Learned to Stop Worrying and Love Spaces](https://reader035.vdocuments.site/reader035/viewer/2022070113/6059c340d48e7a4df96951b3/html5/thumbnails/20.jpg)
Thanks!