+ All Categories
Home > Software > Why Clean Code needed Software Development

Why Clean Code needed Software Development

Date post: 16-Apr-2017
Category:
Upload: md-arefin
View: 384 times
Download: 0 times
Share this document with a friend
13
CLEAN CODE A Summary
Transcript
Page 1: Why Clean Code needed Software Development

CLEAN CODEA Summary

Page 2: Why Clean Code needed Software Development

What is Clean Code?

Easy for others to change

Easy for others to read

Focused on a particular ‘thing’

Completely covered by tests

Page 3: Why Clean Code needed Software Development

Why is Clean Code Important?

Easy to Read, Easy to Change

The ratio of time spent reading vs. writing is well over 10:1.

“You know you are working on clean code when each routine you read turns out to be pretty much what you expected.” – Ward Cunningham

Page 4: Why Clean Code needed Software Development

Causes of Poor Code Quality

Inexperience

Lack of time

Laziness

Broken Window Theory

Page 5: Why Clean Code needed Software Development

Boy Scout Rule

Leave the campground cleaner than you found it.

Page 6: Why Clean Code needed Software Development

Naming Guidelines Names should reveal intent

You may change them repeatedly

Avoid misleading names

If you can’t pronounce it, don’t use it

Longer names > Shorter names

Avoid prefixes & type encoding

Page 7: Why Clean Code needed Software Development

Nouns vs Verbs

• Nouns• Representing

things in the real world

Classes/

Objects

• Verbs• An action being

taken by the object

Methods

Page 8: Why Clean Code needed Software Development

Private Constructors & Static Methods

Consider using static factory methods to call parameterized constructors

Student.CreateStudentFirstNameLastName(“Jason”, “Rosado”);

vs

new Student(“Jason”, “Rosado”);

Page 9: Why Clean Code needed Software Development

Rules of Thumb Keep methods as short as possible (< 20

lines) If statements & loops should only

contain method calls

Page 10: Why Clean Code needed Software Development

Single Responsibility Principle

Be one thing, do one thing

Page 11: Why Clean Code needed Software Development

Comments Comments describe things that our code

cannot

int temp = 0; // temperature in celsius

int temperatureInCelsius= 0;

Use more descriptive names instead of comments

Page 12: Why Clean Code needed Software Development

Bad Comments - Continued

Useless or Redundant Comments

Incorrect

Comments

Page 13: Why Clean Code needed Software Development

Good Comments

Warnings of bad things if code is deleted

Future things that need to be added


Recommended