clean code - sdd conference · 2017. 5. 5. · about me independent consultant education b.s. in...
TRANSCRIPT
![Page 1: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/1.jpg)
Clean Code:A Reader-Centered Approach
@matthewrenze
#sddconf
![Page 2: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/2.jpg)
![Page 3: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/3.jpg)
![Page 4: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/4.jpg)
![Page 5: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/5.jpg)
![Page 6: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/6.jpg)
![Page 7: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/7.jpg)
About Me
Independent consultant
EducationB.S. in Computer Science (ISU)
B.A. in Philosophy (ISU)
CommunityPublic Speaker
Pluralsight Author
Microsoft MVP
ASPInsider
Open-Source Software
![Page 8: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/8.jpg)
Overview
Clean Code
Names
Functions
Classes
Comments
Process
![Page 9: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/9.jpg)
Source: http://www.bernie-eng.com/blog/wp-content/uploads/2011/03/code.jpg
![Page 10: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/10.jpg)
What is Bad Code?
Difficult to read
Difficult to understand
Difficult to maintain
Contains bugs
Contains surprises
![Page 11: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/11.jpg)
The Total Cost of Owning a Mess
Source: Clean Code
![Page 12: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/12.jpg)
Source: http://talkingincode.com/wp-content/uploads/2014/12/crapcode.png
![Page 13: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/13.jpg)
![Page 14: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/14.jpg)
The way we avoid a mess is by keeping our code clean.
![Page 15: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/15.jpg)
What is Clean Code?
![Page 16: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/16.jpg)
What is Clean Code?
Simple and direct
Reads like well-written prose
Never obscures the designer’s intent
Full of crisp abstractions
Contains straight-forward lines of controlGrady Booch
Co-inventor of UML
![Page 17: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/17.jpg)
What is Clean Code?
Runs all the tests
Expresses all the design ideas in the system
Minimizes the number of entities
Minimizes duplication
Expresses ideas clearlyRon Jeffries
Co-inventor of XP
![Page 18: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/18.jpg)
What is Clean Code?
Readable by others
Has unit tests
Has meaningful names
Has minimal dependencies
Do one thingDave Thomas
Co-Author of The Pragmatic Programmer
![Page 19: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/19.jpg)
What is Clean Code?
“You know you are working on clean code when each routine you read turns out to be pretty much what you expected.”
Ward CunninghamInventor of the Wiki
Co-inventor of XP
![Page 20: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/20.jpg)
What is Clean Code?
Simple
Readable
Understandable
Maintainable
Testable Matthew RenzeGenius, Billionaire, Playboy,
Philanthropist : )
![Page 21: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/21.jpg)
What is Clean Code?
Code that is written for the reader of the code… not for the author… or the machine
![Page 22: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/22.jpg)
Why Should We Invest in Clean Code?
Sources: • Barry Boehm - Software Engineering Economics, Prentice Hall • Schach, R., Software Engineering, Fourth Edition, McGraw-Hill• Glass, Robert, Frequently Forgotten Fundamental Facts about Software Engineering
![Page 23: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/23.jpg)
Why Should We Invest in Clean Code?
Source: Clean Code
![Page 24: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/24.jpg)
Clean Code is an Investment
Clean code makes it easier to:Write new code
Maintain old code
Invest in code readability
![Page 25: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/25.jpg)
How Do You Write Clean Code?
Write code for the reader
Not for the author
Not for a machine
![Page 26: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/26.jpg)
How Do You Write Clean Code?
“Always code as if the person who ends up maintaining your code is a violent psychopath who knows where you live!”
- Author Unknown
![Page 27: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/27.jpg)
Names
![Page 28: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/28.jpg)
Choose Names Thoughtfully
Inigo Montoya
![Page 29: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/29.jpg)
Use Intention-Revealing Names
// Bad - Terse variable nameint d; // days in queue
// Goodint daysInQueue;
![Page 30: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/30.jpg)
Use Intention-Revealing Names
// Bad – Unclear method nameprivate int Process();
// Goodprivate int ParseCustomerIdFromFile();
![Page 31: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/31.jpg)
Use Names from Problem Domain
// Problem domainpublic class Customer {}
public void AddAccount();
![Page 32: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/32.jpg)
Use Names from Solution Domain
// Solution domainpublic class Factory {}
public void AddToJobQueue();
![Page 33: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/33.jpg)
Use Names from Both Domains
// Both domainspublic class CustomerFactory {}
public void AddAccountToJobQueue();
![Page 34: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/34.jpg)
Avoid Disinformation
// Bad - misleadingISet<Customer> customerList;
![Page 35: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/35.jpg)
Use Pronounceable Names
// Bad – Not pronounceable namespublic class DtaRcrd102{
private DateTime genymdhms;
private DateTime modymdhms;
private string pszqint = "102";}
![Page 36: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/36.jpg)
Use Pronounceable Names
// Bad – Not pronounceable namespublic class DtaRcrd102{
private DateTime genymdhms;
private DateTime modymdhms;
private string pszqint = "102";}
// Good – Pronounceable namespublic class Customer{
private DateTime generationTimestamp;
private DateTime modificationTimestamp;
private string recordId = "102";}
![Page 37: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/37.jpg)
Avoid Encodings
// Bad – Hungarian Notationprivate int intSomeValue = 123;
![Page 38: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/38.jpg)
Avoid Encodings
// Bad - Module prefixesprivate int m_SomeField = 0;
![Page 39: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/39.jpg)
Avoid Encodings
// OK... Maybe?private int _someField = 0;
![Page 40: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/40.jpg)
Class Names
// Good - Noun or noun phrasepublic class Customer
public class AddressParser
public class AddAccountCommand
![Page 41: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/41.jpg)
Class Names
// Bad - Fuzzy namespublic class ObjectManager
public class EntityProcessor
public class Stuff
// Good - Noun or noun phrasepublic class Customer
public class AddressParser
public class AddAccountCommand
![Page 42: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/42.jpg)
Method Names
// Good - Verb or verb phrasepublic void AddCustomer()
public void DeleteAccount()
public string ParseAddress()
![Page 43: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/43.jpg)
Method Names
// Bad - Fuzzy namespublic string Process()
public void DoWork()
// Good - Verb or verb phrasepublic void AddCustomer()
public void DeleteAccount()
public string ParseAddress()
![Page 44: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/44.jpg)
Method Names
// Good - Boolean predicatespublic bool IsValid()
public bool HasAccount()
![Page 45: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/45.jpg)
Length of Variable Names Should Increase with Scope
// Good - Very short range variable namesfor (int i = 0; i < 10; i++) {}
list.Sum(p => p.GetAmount());
![Page 46: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/46.jpg)
Length of Variable Names Should Increase with Scope
// Good - Very short range variable namesfor (int i = 0; i < 10; i++) {}
list.Sum(p => p.GetAmount());
// Good - Short method variable namesvar balance = GetAccountBalance();
![Page 47: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/47.jpg)
Length of Variable Names Should Increase with Scope
// Good - Very short range variable namesfor (int i = 0; i < 10; i++) {}
list.Sum(p => p.GetAmount());
// Good - Short method variable namesvar balance = GetAccountBalance();
// Good - Longer field variable namesprivate int totalAccountBalance = 0;
![Page 48: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/48.jpg)
Length of Variable Names Should Increase with Scope
// Good - Very short range variable namesfor (int i = 0; i < 10; i++) {}
list.Sum(p => p.GetAmount());
// Good - Short method variable namesvar balance = GetAccountBalance();
// Good - Longer field variable namesprivate int totalAccountBalance = 0;
// Good - Even longer global variable namespublic int totalBalanceInAllBankAccounts;
![Page 49: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/49.jpg)
Length of Method Names Should Decrease with Scope
// Good - Short public method namespublic void GetCustomers();
public void Save();
![Page 50: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/50.jpg)
Length of Method Names Should Decrease with Scope
// Good - Short public method namespublic void GetCustomers();
public void Save();
// Good - Longer private method namesprivate string ParseHtmlFromFile()
private int GetIdFromAccountHolder()
![Page 51: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/51.jpg)
Length of Class Names Should Decrease with Scope
// Good - Short public class namepublic class Account
![Page 52: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/52.jpg)
Length of Class Names Should Decrease with Scope
// Good - Short public class namepublic class Account
// Good - Longer private class nameprivate class AccountNumberGenerator
![Page 53: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/53.jpg)
Length of Class Names Should Decrease with Scope
// Good - Short public class namepublic class Account
// Good - Longer private class nameprivate class AccountNumberGenerator
// Good - Longer derived class namepublic abstract class Account
public class SavingsAccount : Account
![Page 54: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/54.jpg)
Functions
![Page 55: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/55.jpg)
Functions Should Be Small
Simpler
Easier to read
Easier to understand
Easier to test
Contain less bugs
![Page 56: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/56.jpg)
How Small?
Most evidence says:Less than 20 lines
Uncle Bob says:Less than 10 lines
Average 3 to 6 lines
![Page 57: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/57.jpg)
Large Functions are Where Classes Go to Hide
![Page 58: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/58.jpg)
Functions Should Do One Thing
Source: http://www.wengerna.com/giant-knife-16999
![Page 59: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/59.jpg)
One Level of Abstraction per Function
// Good - Separate levels of abstractionpublic File CreateFile()
public Html RenderHtml()
private string RenderHtmlBody()
private string RenderHtmlElement()
private char RenderHtmlElementClosingTag()
![Page 60: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/60.jpg)
Minimize the Number of Parameters
// Try to minimize the # of argumentspublic void SetNone() {}
public void SetOne(int arg1)
public void SetTwo(int arg1, int arg2)
public void SetThree(int arg1, int arg2, int arg3)
public void SetMany(Args args)
![Page 61: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/61.jpg)
Avoid Flag Arguments
// Bad – Flag argumentspublic void Render(bool useColor)
![Page 62: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/62.jpg)
Avoid Flag Arguments
// Bad – Flag argumentspublic void Render(bool useColor)
// Good – No flag argumentspublic void RenderInColor()
public void RenderInGrayScale()
![Page 63: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/63.jpg)
Avoid Output Arguments
// Bad - Uses ‘out’ argumentpublic void AppendFooter(out Report report) {…
}
AppendFooter(out report);
![Page 64: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/64.jpg)
Avoid Output Arguments
// Bad - Uses ‘out’ argumentpublic void AppendFooter(out Report report) {…
}
AppendFooter(out report);
// Good - No ‘out’ argumentpublic ReportBuilder AppendFooter(){…
}
reportBuilder.AppendFooter();
![Page 65: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/65.jpg)
Command-Query Separation
CommandDoes something
Should modify state
Should not return a value
![Page 66: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/66.jpg)
Command-Query Separation
CommandDoes something
Should modify state
Should not return a value
QueryAnswers a question
Should not modify state
Always returns a value
![Page 67: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/67.jpg)
Command-Query Separation
CommandDoes something
Should modify state
Should not return a value
QueryAnswers a question
Should not modify state
Always returns a value
Avoid mixing the two!
![Page 68: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/68.jpg)
Avoid Side Effects
![Page 69: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/69.jpg)
Avoid Duplication
Source: Sony Pictures Home Entertainment
![Page 70: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/70.jpg)
Use Functions to Enhance Readability
// Bad – One giant chunk of codepublic void CreateReport(){... Giant block of code ...
}
![Page 71: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/71.jpg)
Use Functions to Enhance Readability
// Bad – One giant chunk of codepublic void CreateReport(){... Giant block of code ...
}
// Good – Uses small named functionspublic void CreateReport(){
CreateHeader();
CreateBody();
CreateFooter();}
![Page 72: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/72.jpg)
Classes
![Page 73: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/73.jpg)
Classes Should Be Small
Similar benefits as small functions
Single-Responsibility Principle
![Page 74: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/74.jpg)
How Small?
Source: Clean Code
![Page 75: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/75.jpg)
Classes Should Be Narrow
Source: Clean Code
![Page 76: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/76.jpg)
Follow the Law of Demeter
// Bad - Law of Demeter violationvar rent = customer.Pocket.Wallet
.Money.GetRentMoney();
![Page 77: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/77.jpg)
Follow the Law of Demeter
// Bad - Law of Demeter violationvar rent = customer.Pocket.Wallet
.Money.GetRentMoney();
// Good - No violationvar rent = customer.GetRentMoney();
![Page 78: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/78.jpg)
Follow the Law of Demeter
// Bad - Law of Demeter violationvar rent = customer
.Pocket.Wallet
.Money.GetRentMoney();
// Good - No violationvar rent = customer.GetRentMoney();
Source: Athens Banner-Herald
![Page 79: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/79.jpg)
Object vs. Data Structure
public class Rectangle{
private double x;...public double GetX(){
return x;}...public double GetArea(){
return width * height;}
}
![Page 80: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/80.jpg)
Object vs. Data Structure
public class Rectangle{
private double x;...public double GetX(){
return x;}...public double GetArea(){
return width * height;}
}
public struct Rectangle{
public double X;
public double Y;
public double Width;
public double Height;}
![Page 81: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/81.jpg)
Avoid Hybrid Object/Structures
Source: http://www.layoutsparks.com/1/147428/alien-resurrection-scary-dreadful-31000.html
![Page 82: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/82.jpg)
Have a Consistent Order
public class SomeClass{
private const int SomeConst = 123;
private int _someField;
private int SomeProperty {...}
public SomeClass() {...}
public void DoSomethingPublic() {...}
private void DoSomethingPrivate() {...}}
![Page 83: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/83.jpg)
Choose the Right Abstractions
Model
View
Controller
Repository
Factory
Builder
Adapter
![Page 84: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/84.jpg)
Other Practices for Classes
DRY Principle
High Cohesion
Low Coupling
Dependency Injection
Testability
![Page 85: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/85.jpg)
Comments
![Page 86: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/86.jpg)
Comments Represent a Failure
Source: http://a.tgcdn.net/images/products/zoom/no_comment.jpg
![Page 87: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/87.jpg)
Obsolete Comments Lie
![Page 88: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/88.jpg)
Explain Yourself in Code// Bad - Code explained in comment
// Check to see if the employee is eligible for full benefits
if ((employee.FullTime || SalaryFlag)
&& (employee.Age > 65))
![Page 89: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/89.jpg)
Explain Yourself in Code// Bad - Code explained in comment
// Check to see if the employee is eligible for full benefits
if ((employee.FullTime || SalaryFlag)
&& (employee.Age > 65))
// Good - Code explains itself
private bool IsEligibleForFullBenefits(Employee employee)
{
return ((employee.FullTime || SalaryFlag)
&& employee.Age > 65))
}
![Page 90: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/90.jpg)
Explain Yourself in Code// Bad - Code explained in comment
// Check to see if the employee is eligible for full benefits
if ((employee.FullTime || SalaryFlag)
&& (employee.Age > 65))
// Good - Code explains itself
private bool IsEligibleForFullBenefits(Employee employee)
{
return ((employee.FullTime || SalaryFlag)
&& employee.Age > 65))
}
if (IsEligibleForFullBenefits(employee))
![Page 91: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/91.jpg)
Bad Comments
// All of these comments are bad
// Opens the filevar file = File.Open();
// Returns day of monthprivate int GetDayOfWeek()
// 08-07-2013 – Fixed Bug (MLR)
Main(){…
} // end main
![Page 92: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/92.jpg)
Zombie Code
// Zombie Code// if (a == 1)// b = c + 1
Source: The Walking Dead
![Page 93: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/93.jpg)
Zombie Code
// Zombie Code// if (a == 1)// b = c + 1
Source: The Walking Dead
Kill it with fire!
![Page 94: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/94.jpg)
Necessary Comments
// Copyright © 2017 Matthew Renze
// Trim is necessary to prevent a// search term mismatch
// Warning: Slow running test
// TODO: Refactor to factory pattern
/// <summary>/// Opens the file for reading/// </summary>
![Page 95: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/95.jpg)
The Best Comment is No Comment at All
(but only if our code clearly explains itself)
![Page 96: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/96.jpg)
The Process
![Page 97: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/97.jpg)
The Principles
Test-Driven Development (TDD)
Simplicity (KISS)
Continuous Refactoring
Red
GreenRefactor
![Page 98: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/98.jpg)
Test-Driven Development Process
1. Create a failing unit test
2. Code the simplest thing
3. Refactor until the code is clean
Red
GreenRefactor
![Page 99: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/99.jpg)
Test-Driven Development
Starts with a test
Tests drive the design
Code evolves over time
Red
GreenRefactor
![Page 100: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/100.jpg)
TDD Code is:
Testable
Maintainable
Reliable
Self-documenting
Clean
Easy to keep clean
Red
GreenRefactor
![Page 101: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/101.jpg)
Simplicity
Keep it Simple (KISS)
Unnecessary complexity
You Ain’t Gonna Need It (YAGNI)
Incremental algorithmics
Red
GreenRefactor
![Page 102: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/102.jpg)
Continuous Refactoring
Working code is not the last step
Refactor until clean
Continuous process
Red
GreenRefactor
![Page 103: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/103.jpg)
Continuous Refactoring
All creative endeavors are iterative processes
Red
GreenRefactor
![Page 104: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/104.jpg)
Follow the Boy Scout Rule
“Leave the campground just a little bit cleaner than you found it.”
– adapted from Robert Stephenson Smyth Baden-Powell’s farewell message to the scouts: “Try and leave this world a little better than you found it.”
![Page 105: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/105.jpg)
“Leave the campground just a little bit cleaner than you found it.”
![Page 106: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/106.jpg)
Conclusion
![Page 107: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/107.jpg)
Conclusion
Clean code is:Simple
Readable
Understandable
Maintainable
Testable
Clean code is a philosophy of writing code for the reader
![Page 108: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/108.jpg)
Conclusion
Use intention revealing names
Classes and functions should be small
Use comments to express a failure
The process is:1. Test First (TDD)
2. Simplest solution
3. Continuously refactor
![Page 109: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/109.jpg)
Where to Go Next
![Page 110: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/110.jpg)
Where to Go Next
![Page 111: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/111.jpg)
Where to Go Next
http://pluralsight.com/training/Courses/TableOfContents/writing-clean-code-humans
![Page 112: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/112.jpg)
Where to Go Next
Articles
Courses
Presentations
Source Code
Videos
www.matthewrenze.com
![Page 113: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/113.jpg)
Feedback
Feedback is very important to me!
One thing you liked?
One thing I could improve?
![Page 114: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/114.jpg)
“Programming is not about telling the computer what to do.
Programming is the art of telling another human what the computer should do.”
- Donald Knuth
![Page 115: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/115.jpg)
“Any fool can write code that a computer can understand.
Good programmers write code that humans can understand.”
- Martin Fowler
![Page 116: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/116.jpg)
“To leave the campground just a little bit cleaner than you found it.”
Uncle Bob Wants You:
![Page 117: Clean Code - SDD Conference · 2017. 5. 5. · About Me Independent consultant Education B.S. in Computer Science (ISU) B.A. in Philosophy (ISU) Community Public Speaker Pluralsight](https://reader033.vdocument.in/reader033/viewer/2022052000/6011b61264b9362e7564ce73/html5/thumbnails/117.jpg)
Contact Info
Matthew Renze
Data Science Consultant
Renze Consulting
Twitter: @matthewrenze
Email: [email protected]
Website: www.matthewrenze.com
Thank You! : )