URBAN & REGIONAL DEVELOPMENT IN ROMANIA Daniela Iulia SGARCITU ROMANIA.
Clean Code @Agileworks Romania 2013 05 23
-
Upload
adi-bolboaca -
Category
Technology
-
view
243 -
download
3
description
Transcript of Clean Code @Agileworks Romania 2013 05 23
Clean Code
Clean Code
Adi Boboacă
@adibolb
Alex Bolboacă
@alexboly
Clean Code
Clean Code – Environment
Build Requires One StepBuild time is manageable
Tests Execution Requires One StepAlways Use Source ControlHave Continuous Integration
Code Smell
SniffableEasy to spot
Does not always indicate a problem
www.mozaicworks.com
Code Smell
A code smell is a hint that shows you might have a problem in your system. '
www.mozaicworks.com
Coding Smells - Design
Misplaced ResponsibilityCode at Wrong abstraction Level
Fields Define Temp VariablesHidden Temporal Coupling
Over-engineeringUsage of Singleton / Statics / newInterface Has Too Many Methods
Clean Code - Design
Be PreciseDon't Be Arbitrary
Keep Configuration at High LevelsPrefer Polymorphism Over conditionalsPrefer Composition Over Inheritance
S.O.L.I.D.
Coding Smells – Naming
There Are Several Naming StandardsMore Names Mean The Same Concept
Someone Needs To Explain You The Code
Clean Code – Naming
Use Standards For The LanguageNames Use Domain LanguageNames Describe The Intention
Names Do Not Use Hungarian NotationNames Do Not Contain Encodings
Coding Smells - Methods
Method Has More Than 3 IndentsMethod Uses Getters From Other Classes
There Are Static MethodMethods & Ctors Have More Than 3 Args
Arguments Have out Or ref
Clean Code - Methods
Have Only One ResponsibilityUse Only Internal State (No Feature Envy)
Avoid StaticHave Maximum Two Arguments
Do Not Pass Reference As Arguments
Coding Smells - Variables
You see a, i, bla, etc. As VariablesYou see string, int, float, In ClassesThere Are Static Variables In Classes
Use Integers for Currency
Clean Code - Variables
Use Explanatory VariablesAlways Encapsulate Primitives
Avoid StaticsUse Appropriate Types
Clean Code - General
Boy Scout RuleKeep It Simple, Stupid (KISS)Delete Commented Code
Delete Unused CodeMinimize Duplication
Clean Code
http://www.mozaicworks.com
Extend your mentoring & training capacity
Accelerate learning through communities of practice
Grow your functional leaders and top talents
@alexboly @adibolb