clean code and common engineering practices
TRANSCRIPT
![Page 1: Clean Code and Common Engineering Practices](https://reader031.vdocuments.us/reader031/viewer/2022032216/55a69bb11a28abe77d8b464e/html5/thumbnails/1.jpg)
CLEAN CODE AND ENGINEERING PRACTICESRuth Sperer – Tech Lead and EP ChampionAT&T Israel
![Page 2: Clean Code and Common Engineering Practices](https://reader031.vdocuments.us/reader031/viewer/2022032216/55a69bb11a28abe77d8b464e/html5/thumbnails/2.jpg)
OVERVIEW▪ Clean code principles
▪ Code Review
▪ TDD
▪ Refactoring
▪ SCM, SCA, CI and other abbreviations
▪ Being a good programmer
![Page 3: Clean Code and Common Engineering Practices](https://reader031.vdocuments.us/reader031/viewer/2022032216/55a69bb11a28abe77d8b464e/html5/thumbnails/3.jpg)
WHAT DO YOU CONSIDER CLEAN CODE?▪ Readable
▪ Error free
▪ Elegant
▪ Testable
▪ Efficient
![Page 4: Clean Code and Common Engineering Practices](https://reader031.vdocuments.us/reader031/viewer/2022032216/55a69bb11a28abe77d8b464e/html5/thumbnails/4.jpg)
MEANINGFUL NAMES▪ For class, method or variable, name should suggest
▪ Why is exists
▪ What it does
▪ How it is used
▪ Don’t include type info▪ Why?
▪ Be honest▪ No side effects
▪ So what about comments?
![Page 5: Clean Code and Common Engineering Practices](https://reader031.vdocuments.us/reader031/viewer/2022032216/55a69bb11a28abe77d8b464e/html5/thumbnails/5.jpg)
WHAT MAKES A GOOD FUNCTION?▪ Short
▪ Efficient
▪ Does one thing
▪ Reusable
▪ Few variables
▪ No side effects
![Page 6: Clean Code and Common Engineering Practices](https://reader031.vdocuments.us/reader031/viewer/2022032216/55a69bb11a28abe77d8b464e/html5/thumbnails/6.jpg)
CODE REVIEW - MOTIVATIONDefinition: The analysis of source code in order to find defects
▪Early bug detection
▪Knowledge sharing
▪Code improvements
▪Social communication
▪Understanding
* Expectations vs. Actual
![Page 7: Clean Code and Common Engineering Practices](https://reader031.vdocuments.us/reader031/viewer/2022032216/55a69bb11a28abe77d8b464e/html5/thumbnails/7.jpg)
CODE REVIEW – PRACTICAL GUIDE▪ Let the tools work for you:
▪ Formatter
▪ Lint
▪ Find problems, not solutions
▪ As a reviewer – be nice
▪ As a reviewed – leave you ego in the drawer
▪ Don’t skip it (no valid excuses)
![Page 8: Clean Code and Common Engineering Practices](https://reader031.vdocuments.us/reader031/viewer/2022032216/55a69bb11a28abe77d8b464e/html5/thumbnails/8.jpg)
TDD
![Page 9: Clean Code and Common Engineering Practices](https://reader031.vdocuments.us/reader031/viewer/2022032216/55a69bb11a28abe77d8b464e/html5/thumbnails/9.jpg)
REFACTORING▪ Why ?
▪ Cost of owning a mess*:
▪ Don’t make it to “The grand re-design”*
▪ Code that smells▪ Duplicate code▪ Longs methods▪ Deep nesting▪ Too many variables in a method
* Rober C Marting – “Clean Code..”
![Page 10: Clean Code and Common Engineering Practices](https://reader031.vdocuments.us/reader031/viewer/2022032216/55a69bb11a28abe77d8b464e/html5/thumbnails/10.jpg)
REFACTORING TIPS▪ Valid changes – let your IDE work for you
▪ Renaming
▪ Extract variable
▪ Extract method
▪ Move
▪ Introduce parameter
▪ Unit tests coverage is your friend
![Page 11: Clean Code and Common Engineering Practices](https://reader031.vdocuments.us/reader031/viewer/2022032216/55a69bb11a28abe77d8b464e/html5/thumbnails/11.jpg)
SCM – SOFTWARE CONFIGURATION MANAGEMENT▪ Track and control changes in software
▪ Confidence in change - Can always go back
▪ When to start using it?
▪ Git – free and open source
▪ Github – host
▪ Other free/commercial tools – CVS, SVN, ClearCase
![Page 12: Clean Code and Common Engineering Practices](https://reader031.vdocuments.us/reader031/viewer/2022032216/55a69bb11a28abe77d8b464e/html5/thumbnails/12.jpg)
SCA – STATIC CODE ANALYSIS▪ Analyzing code without executing it
▪ Common Errors detectible by SCA▪ Buffers and arrays underflows \ overflows
▪ Resource leaks
▪ Potential null references
▪ Lack of initialization
▪ Common tools: Sonar, FindBugs, Checkstyle
![Page 13: Clean Code and Common Engineering Practices](https://reader031.vdocuments.us/reader031/viewer/2022032216/55a69bb11a28abe77d8b464e/html5/thumbnails/13.jpg)
CI – CONTINUOUS INTEGRATION▪ is the practice of merging all developer working copies with a
shared mainline several times a day
▪ Considered an XP (extreme programming) habit
▪ Possibly dozens of “commits” every day
▪ Prevent “Integration Hell”
▪ Automated unit tests in build server
▪ Next step: CD – Continuous Delivery
![Page 14: Clean Code and Common Engineering Practices](https://reader031.vdocuments.us/reader031/viewer/2022032216/55a69bb11a28abe77d8b464e/html5/thumbnails/14.jpg)
BEING A GOOD PROGRAMMER▪ Respect your ancestors
▪ The Netscape rewrite story
▪ Acknowledge your successors▪ Meaningful names, Comments
▪ Avoid code duplications
▪ “Leave the camp ground cleaner than you found it”
![Page 15: Clean Code and Common Engineering Practices](https://reader031.vdocuments.us/reader031/viewer/2022032216/55a69bb11a28abe77d8b464e/html5/thumbnails/15.jpg)
RECOMMENDED READINGS▪ "Clean Code: A Handbook of Agile Software Craftsmanship“ by Robert
C. Martins
▪ “The Pragmatic Programmer” by Dave Thomas and Andy Hunt
▪ Effective <fill in your language>