Lets talk About Good Code (Dallas TechFest 2014)

21
©2010 Improving Enterprises, Inc. Good Code What, Why, and How to Get There Dallas TechFest 2014 Jane Prusakova Josh Rizzo @Improving Enterprises College Station

description

Many programmers are dedicated, or even obsessed, with writing “good” code. Often we follow certain patterns and practices because we believe they are the best solution for the problem, or because the “experts” tell us to. In this session, we will discuss what good code really is and what benefits it brings.Presented by Josh Rizzo and Jane Prusakova, Improving BCS.

Transcript of Lets talk About Good Code (Dallas TechFest 2014)

Page 1: Lets talk About Good Code (Dallas TechFest 2014)

©2010 Improving Enterprises, Inc.

Good CodeWhat, Why, and How to Get There

Dallas TechFest 2014Jane Prusakova

Josh Rizzo@Improving Enterprises College Station

Page 2: Lets talk About Good Code (Dallas TechFest 2014)

©2010 Improving Enterprises, Inc.

What is “good”?

FunctionalBug-freePerformantGood designTestedTestableEasy to change

READABLE

Page 3: Lets talk About Good Code (Dallas TechFest 2014)

©2010 Improving Enterprises, Inc.

Usability

Users and clients Developers

Page 4: Lets talk About Good Code (Dallas TechFest 2014)

©2010 Improving Enterprises, Inc.

Page 5: Lets talk About Good Code (Dallas TechFest 2014)

©2010 Improving Enterprises, Inc.

“Programs must be written for people to read, and only incidentally for machines to execute.”

– Abelson and Sussman

Page 6: Lets talk About Good Code (Dallas TechFest 2014)

©2010 Improving Enterprises, Inc.

Readability has valueNOW

Code is an asset

affects productivity

monetary value

Page 7: Lets talk About Good Code (Dallas TechFest 2014)

Readability has value OVER TIME

Software evolves over time

Work by many different teams

Changes affect value

Page 8: Lets talk About Good Code (Dallas TechFest 2014)

©2010 Improving Enterprises, Inc.

Readability has cost

More hard work

More time

More training

Page 9: Lets talk About Good Code (Dallas TechFest 2014)

©2010 Improving Enterprises, Inc.

Readable code

Easy to readHas a narrative

UnambiguousWYSIWYG

Follows convention

Page 10: Lets talk About Good Code (Dallas TechFest 2014)

©2010 Improving Enterprises, Inc.

Who is responsible?

It was hard to write It should be hard to read

Page 11: Lets talk About Good Code (Dallas TechFest 2014)

©2010 Improving Enterprises, Inc.

Lets make code more…

READABLESee: https://github.com/joshrizzo/Readability

Page 12: Lets talk About Good Code (Dallas TechFest 2014)

©2010 Improving Enterprises, Inc.

Visible codeShort and concise

Spacing and indent matter

“If we wish to count lines of code, we should not regard them as ‘lines produced’ but as ‘lines spent.’”

– Edsger Dijkstra

Page 13: Lets talk About Good Code (Dallas TechFest 2014)

©2010 Improving Enterprises, Inc.

Code with a narrativeUse naming to show intent

Interface design

“Programming can be fun, so can cryptography; however they should not be combined.”

– Kreitzberg and Shneiderman

Page 14: Lets talk About Good Code (Dallas TechFest 2014)

©2010 Improving Enterprises, Inc.

Easy to read

Cohesive level of abstraction

“The purpose of abstraction is not to be vague, but to create a new semantic level in which one can be absolutely precise.”  

– Edsger Dijkstra

Page 15: Lets talk About Good Code (Dallas TechFest 2014)

©2010 Improving Enterprises, Inc.

Readable++Simplicity

Page 16: Lets talk About Good Code (Dallas TechFest 2014)

©2010 Improving Enterprises, Inc.

“Everything should be made as simple as possible, but not simpler.”

– Albert Einstein

Page 17: Lets talk About Good Code (Dallas TechFest 2014)

©2010 Improving Enterprises, Inc.

Simple vs Fast

Correctness more important than speedSimple code is more likely to be and stay correct

Modularize code w/ performance concernsOptimize locally

Page 18: Lets talk About Good Code (Dallas TechFest 2014)

©2010 Improving Enterprises, Inc.

Page 19: Lets talk About Good Code (Dallas TechFest 2014)

©2010 Improving Enterprises, Inc.

Simple vs FlexibleRe-use is rare

Predictions of re-use are poor

Raises complexity significantly

Unused => not working

Page 20: Lets talk About Good Code (Dallas TechFest 2014)

©2010 Improving Enterprises, Inc.

Simple vs Clever

Over engineering

Mixing abstractions

Inappropriate patterns

Complicated syntax

Page 21: Lets talk About Good Code (Dallas TechFest 2014)

©2010 Improving Enterprises, Inc.

Good CodeWhat, Why, and How to Get There

https://github.com/joshrizzo/Readability

Dallas TechFest 2014Jane Prusakova

Josh Rizzo@Improving Enterprises College Station