fundamentals of software development 1slide 1 code reviews what are they?what are they? why do...

6
Fundamentals of Softw are Development 1 Slide 1 Code Reviews Code Reviews What are they? What are they? Why do them? Why do them?

Post on 15-Jan-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Fundamentals of Software Development 1Slide 1 Code Reviews What are they?What are they? Why do them?Why do them?

Fundamentals of Software Development 1

Slide 1

Code ReviewsCode Reviews

• What are they?What are they?• Why do them?Why do them?

Page 2: Fundamentals of Software Development 1Slide 1 Code Reviews What are they?What are they? Why do them?Why do them?

Fundamentals of Software Development 1

Slide 2

What are Code ReviewsWhat are Code Reviews

• Other team members read code before it is Other team members read code before it is added to the project to look for…added to the project to look for…– Logical correctnessLogical correctness

• For example a ball is destroyed from view but still For example a ball is destroyed from view but still liveslives

– Code conventionsCode conventions• public class myfavoriteclass { ….public class myfavoriteclass { ….

– Code readabilityCode readability• if (i>0) i=i; else i=-i;if (i>0) i=i; else i=-i;

– Graceful error handlingGraceful error handling• For example the ball to be destroyed does not existFor example the ball to be destroyed does not exist

– PerformancePerformance• half = i*0.5;half = i*0.5; oror half = i/2;half = i/2;

– Many others…Many others…

Page 3: Fundamentals of Software Development 1Slide 1 Code Reviews What are they?What are they? Why do them?Why do them?

Fundamentals of Software Development 1

Slide 3

Why perform Code Why perform Code ReviewsReviews

• Help save time and money and increase Help save time and money and increase reliability…reliability…– Identifies problems early…Identifies problems early…

• So they are easier to fixSo they are easier to fix

– Helps new software developers integrate into the Helps new software developers integrate into the team…team…• Understand the systemUnderstand the system• Learn from othersLearn from others

– Facilitates teamwork…Facilitates teamwork…• Helps team communication and awarenessHelps team communication and awareness

– Produces better code…Produces better code…• More logically correctMore logically correct• Follow code conventionsFollow code conventions• Easier to read and maintainEasier to read and maintain

Page 4: Fundamentals of Software Development 1Slide 1 Code Reviews What are they?What are they? Why do them?Why do them?

Fundamentals of Software Development 1

Slide 4

Example Code from Example Code from BouncerBouncer

public void act() { public void act() { super.act(); super.act();

Point2D myPoint = new Point2D.Double(this.xloc,this.yloc);Point2D myPoint = new Point2D.Double(this.xloc,this.yloc);if (!this.myManager.isTrue1(myPoint)){ if (!this.myManager.isTrue1(myPoint)){

int i = this.XV/(-1);int i = this.XV/(-1);this.XV = i;this.XV = i;

} } if (!this.myManager.isTrue2(myPoint)){if (!this.myManager.isTrue2(myPoint)){

int i = this.YV/(-1);int i = this.YV/(-1);this.YV = i;this.YV = i;

} } }}

Page 5: Fundamentals of Software Development 1Slide 1 Code Reviews What are they?What are they? Why do them?Why do them?

Fundamentals of Software Development 1

Slide 5

Example Code from Example Code from BouncerBouncer

public void act() { public void act() { // Overrides the super’s act...// Overrides the super’s act... super.act(); super.act(); // Calls the code for same routine in super// Calls the code for same routine in super Point2D myPoint = new Point2D.Double(this.xloc,this.yloc);Point2D myPoint = new Point2D.Double(this.xloc,this.yloc); // Make it bounce in x or y direction as appropriate!// Make it bounce in x or y direction as appropriate! if (!this.myManager.if (!this.myManager.isInsideWorldXisInsideWorldX(myPoint)){ (myPoint)){ this.xVeloc = - this.this.xVeloc = - this.xVelocxVeloc;; } } if (!this.myManager.if (!this.myManager.isInsideWorldYisInsideWorldY(myPoint)){(myPoint)){ this.yVeloc = - this.this.yVeloc = - this.yVelocyVeloc;; } } }}

Indent properly!

Use descriptive names!

Fields start with lower case

(also use descriptive

names!Simplify Logic!

Add comments!

Page 6: Fundamentals of Software Development 1Slide 1 Code Reviews What are they?What are they? Why do them?Why do them?

Fundamentals of Software Development 1

Slide 6

SummarySummary• Other team members check code before it is Other team members check code before it is

added to the project to look for…added to the project to look for…– Logical correctnessLogical correctness– Code conventionsCode conventions– Code readabilityCode readability– Graceful error handlingGraceful error handling– PerformancePerformance

• Help save time and money and increase Help save time and money and increase reliability…reliability…– Identifies problems earlyIdentifies problems early– Helps new software developers integrate into the Helps new software developers integrate into the

teamteam– Facilitates teamworkFacilitates teamwork– Produces better codeProduces better code