The Eye of the Beholder QCon San Francisco 2011 Alex Papadimoulis - - PowerPoint PPT Presentation

the eye of the beholder
SMART_READER_LITE
LIVE PREVIEW

The Eye of the Beholder QCon San Francisco 2011 Alex Papadimoulis - - PowerPoint PPT Presentation

Beauty is in The Eye of the Beholder QCon San Francisco 2011 Alex Papadimoulis @apapadimoulis Software Disaster Stories Interviews Gone Bad Bad Code Funny Error Messages And sometimes serious content! The day job


slide-1
SLIDE 1

Beauty is in The Eye of the Beholder

QCon San Francisco 2011 Alex Papadimoulis @apapadimoulis

slide-2
SLIDE 2
  • Software Disaster Stories
  • Interviews Gone Bad
  • Bad Code
  • Funny Error Messages
  • And sometimes… serious content!
slide-3
SLIDE 3
  • The day job
  • BuildMaster

–release management & automation –continuous delivery platform

slide-4
SLIDE 4

My 3 Bullet Point Résumé

  • Been in software for a while
  • Worked on a bunch of different systems
  • Worked at a bunch of different places
slide-5
SLIDE 5

IS S IT HO HOT OR OR NO NOT?

Let’s play a game!

slide-6
SLIDE 6

%DTC %DTC ; SF/XAK - DATE/TIME OPERATIONS ;1/16/92 11:36 AM ;;19.0;VA FileMan;;Jul 14, 1992 D I 'X1!'X2 S X="" Q S X=X1 D H S X1=%H,X=X2,X2=%Y+1 D H S X=X1-%H,%Y=%Y+1&X2 K %H,X1,X2 Q ; C S X=X1 Q:'X D H S %H=%H+X2 D YMD S:$P(X1,".",2) X=X_"."_$P(X1,".",2) K X1,X2 Q S S %=%#60/100+(%#3600\60)/100+(%\3600)/100 Q ; H I X<1410000 S %H=0,%Y=-1 Q S %Y=$E(X,1,3),%M=$E(X,4,5),%D=$E(X,6,7) S %T=$E(X_0,9,10)*60+$E(X_"000",11,12)*60+$E(X_"00000",13,14) TOH S %H=%M>2&'(%Y#4)+$P("^31^59^90^120^151^181^212^243^273^304^334","^",%M)+%D S %='%M!'%D,%Y=%Y-141,%H=%H+(%Y*365)+(%Y\4)-(%Y>59)+%,%Y=$S(%:- 1,1:%H+4#7) K %M,%D,% Q ;

slide-7
SLIDE 7
slide-8
SLIDE 8
slide-9
SLIDE 9
slide-10
SLIDE 10
slide-11
SLIDE 11
slide-12
SLIDE 12
slide-13
SLIDE 13
slide-14
SLIDE 14

SURVEY SAYS…

That’s right, I knew the results ahead of time.

slide-15
SLIDE 15
  • Beauty is in the Eye of the Beholder
  • Ugly Code is… just plain ugly
slide-16
SLIDE 16

DEFINING “UGLY” CODE

Can you really quantify aesthetics?

slide-17
SLIDE 17

In Our World…

  • Code is not art
  • We are not craftsman
  • Our work supports or drives business
slide-18
SLIDE 18

Code Quality

  • Good vs. Bad

 “Who cares?”

  • Works vs. Broken  “Bugs are bad!”
  • Beautify vs. Ugly

 ?????

slide-19
SLIDE 19

A Matter of Maintenance

  • Ugly code is difficult to understand
  • More points of failure
  • Costlier and Riskier to Maintain
  • Extra: no one likes maintaining ugly code
slide-20
SLIDE 20

A TAXONOMY ONOMY OF OF UG UGLY

It’s more than just Ugly and Fugly

slide-21
SLIDE 21

Dilapidated & Decrepit

slide-22
SLIDE 22

Dilapidated & Decrepit

slide-23
SLIDE 23

Complex & Convoluted

slide-24
SLIDE 24

Complex & Convoluted

slide-25
SLIDE 25

Complete Clusterfrack

slide-26
SLIDE 26

Complete Clusterfrack

slide-27
SLIDE 27

Maddening Mishmash

slide-28
SLIDE 28

Maddening Mishmash

slide-29
SLIDE 29

Disastrously Disheveled

slide-30
SLIDE 30

Disastrously Disheveled

slide-31
SLIDE 31

NO NOT-SO O BEAUTIFUL IFUL COD ODE

But not quite ugly, either. Homely?

slide-32
SLIDE 32

Old & Over-the-hill

slide-33
SLIDE 33

Old & Over-the-hill

slide-34
SLIDE 34

Freakishly Foreign

slide-35
SLIDE 35

Freakishly Foreign

slide-36
SLIDE 36

Five Kinds of Ugly

  • Dilapidated & Decrepit
  • Complex & Convoluted
  • Complete Clusterfrack
  • Maddening Mishmash
  • Disastrously Disheveled
slide-37
SLIDE 37

THE HE OR ORIGIN IN OF OF UG UGLY COD ODE

It was pretty much born that way.

slide-38
SLIDE 38

Clueless Coders

slide-39
SLIDE 39

Cowboy Coders

slide-40
SLIDE 40

Clever Coders

slide-41
SLIDE 41

“Programmers… often take refuge in an understandable, but disastrous, inclination towards complexity and ingenuity in their

  • work. Forbidden to design anything larger

than a program, they respond by making that program intricate enough to challenge their professional skill.”

  • - Michael A. Jackson, 1975
slide-42
SLIDE 42

Problem:

slide-43
SLIDE 43

New Problem:

use this to build a tool that can pound-in nails

slide-44
SLIDE 44

Ad Infinitum:

slide-45
SLIDE 45

Final Solution:

slide-46
SLIDE 46

Cleverness is Unavoidable

slide-47
SLIDE 47

Clever:

slide-48
SLIDE 48

Clever:

slide-49
SLIDE 49

Clever:

slide-50
SLIDE 50

Oh Dear God!

slide-51
SLIDE 51

“Never attribute to malice that which is adequately explained by stupidity cleverness”

slide-52
SLIDE 52

Where Ugly Doesn’t Come From

  • Development Process
  • Lack of Testing
  • Tools
slide-53
SLIDE 53

PREVEN ENTING TING UGLY COD ODING ING

You too can prevent ugly code.

slide-54
SLIDE 54

Clueing-in the Clueless

  • Clueless by their nature
  • Training and education can help
  • If all else fails… isolation!
slide-55
SLIDE 55

Corral the Cowboys

  • Process
  • Process
  • Process
slide-56
SLIDE 56

Cease the Cleverness

  • Step Back, Re-evaluate
  • Think “Gloves”
  • Get a second or third opinion
slide-57
SLIDE 57

CULLING LING THE HE UGLY COD ODE

“Just take a little off the top”

slide-58
SLIDE 58

Evaluate Organizational Support

  • How much will it take to fix?
  • Why fix what isn’t broken?
slide-59
SLIDE 59

Selling Change

  • It's All About the Benjamins, Baby
  • Value proposition:

–Lower costs –Reduce risk of change –Increase opportunity

slide-60
SLIDE 60

Going Rogue

  • Easier to ask for forgiveness
  • No one will really notice
  • Proper terminology: “upgrade” not “rewrite”
slide-61
SLIDE 61

Stop Writing Ugly Code

  • Clue-in the Clueless
  • Corral the Cowboys
  • Cease the Cleverness
slide-62
SLIDE 62

Create a Demarcation Line

  • Not all ugly code should go
  • Logical boundaries can isolate the ugly
  • Criteria: rate and risk of change
slide-63
SLIDE 63

Abstract the “Legacy”

  • Formalizes Boundaries
  • Makes coding Easier
  • Loose Coupling is a Good Thing™
slide-64
SLIDE 64

Rewrite & Refactor

  • Unit Tests
  • “Feature Toggle” When Possible
  • Small, isolated changes
slide-65
SLIDE 65

Stay Committed

  • Rewriting is boring and tedious
  • Should have ZERO noticeable impact
  • Giving up will make things worse
slide-66
SLIDE 66

Step-by-Step

  • Evaluate Organizational Support
  • Sell Change or Go Rogue
  • Stop Writing Ugly Code
  • Abstract the “Legacy”
  • Rewrite & Refactor
  • Stay Committed
slide-67
SLIDE 67

Much, Much Worse