Lets talk About Good Code (Dallas TechFest 2014)

Post on 08-Dec-2014

106 views 5 download

Tags:

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)

©2010 Improving Enterprises, Inc.

Good CodeWhat, Why, and How to Get There

Dallas TechFest 2014Jane Prusakova

Josh Rizzo@Improving Enterprises College Station

©2010 Improving Enterprises, Inc.

What is “good”?

FunctionalBug-freePerformantGood designTestedTestableEasy to change

READABLE

©2010 Improving Enterprises, Inc.

Usability

Users and clients Developers

©2010 Improving Enterprises, Inc.

©2010 Improving Enterprises, Inc.

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

– Abelson and Sussman

©2010 Improving Enterprises, Inc.

Readability has valueNOW

Code is an asset

affects productivity

monetary value

Readability has value OVER TIME

Software evolves over time

Work by many different teams

Changes affect value

©2010 Improving Enterprises, Inc.

Readability has cost

More hard work

More time

More training

©2010 Improving Enterprises, Inc.

Readable code

Easy to readHas a narrative

UnambiguousWYSIWYG

Follows convention

©2010 Improving Enterprises, Inc.

Who is responsible?

It was hard to write It should be hard to read

©2010 Improving Enterprises, Inc.

Lets make code more…

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

©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

©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

©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

©2010 Improving Enterprises, Inc.

Readable++Simplicity

©2010 Improving Enterprises, Inc.

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

– Albert Einstein

©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

©2010 Improving Enterprises, Inc.

©2010 Improving Enterprises, Inc.

Simple vs FlexibleRe-use is rare

Predictions of re-use are poor

Raises complexity significantly

Unused => not working

©2010 Improving Enterprises, Inc.

Simple vs Clever

Over engineering

Mixing abstractions

Inappropriate patterns

Complicated syntax

©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