unindented code cannot possibly work!

47
#DCAEC12 Unindented Code Cannot Possibly Work! Ed Buhain December 7, 2012 PRIVILEGED AND CONFIDENTIAL. The information contained in this material is privileged and confidential, and is intended only for the use of the individual to whom it is addressed and others who have been specifically authorized to receive it. If you are not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this material is strictly prohibited. If you have received this material in error, please destroy it immediately. #DCAEC12

Upload: excella-consulting

Post on 12-May-2015

187 views

Category:

Documents


2 download

DESCRIPTION

Unindented Code Cannot Possibly Work! was presented at the DC Agile Engineering Conference on 12/7/2012 by Ed Buhain (@buhain).

TRANSCRIPT

Page 1: Unindented Code Cannot Possibly Work!

#DCAEC12

Unindented Code Cannot Possibly Work!

Ed Buhain

December 7, 2012

PRIVILEGED AND CONFIDENTIAL. The information contained in this material is privileged and confidential, and is intended only for the use of the individual to whom it is addressed and others who have been specifically authorized to receive it. If you are not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this material is strictly prohibited. If you have received this material in error, please destroy it immediately. #DCAEC12

Page 2: Unindented Code Cannot Possibly Work!

#DCAEC12

The Ariane 5

$7B development

$500M rocket & cargo

Software Based on the Ariane 4

#DCAEC12

Page 3: Unindented Code Cannot Possibly Work!

#DCAEC12

The Ariane 5

Inertial Reference Systems

On-BoardComputers

Boosters&

Main Engine

#DCAEC12

Page 4: Unindented Code Cannot Possibly Work!

#DCAEC12#DCAEC12

The journey of a thousand miles sometimes ends very, very badly.

- Despair, Inc.

Page 5: Unindented Code Cannot Possibly Work!

#DCAEC12

About Me

NAME: Ed Buhain

COMPANY: Excella Consulting

EMAIL: [email protected]

TWITTER: @buhain

BLOG: blog.buhain.com

Page 6: Unindented Code Cannot Possibly Work!

#DCAEC12

Unindented Code Cannot Possibly Work!

Ed Buhain

December 7, 2012

PRIVILEGED AND CONFIDENTIAL. The information contained in this material is privileged and confidential, and is intended only for the use of the individual to whom it is addressed and others who have been specifically authorized to receive it. If you are not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this material is strictly prohibited. If you have received this material in error, please destroy it immediately. #DCAEC12

Page 7: Unindented Code Cannot Possibly Work!

#DCAEC12#DCAEC12

Page 8: Unindented Code Cannot Possibly Work!

#DCAEC12

SOLID Principles

S - Single Responsibility

O - Open/Closed Principle

L - Liskov SubstitutionI - Interface

SegregationD - Dependency

Inversion

Page 9: Unindented Code Cannot Possibly Work!

#DCAEC12#DCAEC12

Page 10: Unindented Code Cannot Possibly Work!

#DCAEC12#DCAEC12

Page 11: Unindented Code Cannot Possibly Work!

#DCAEC12#DCAEC12

Unindented code cannot possibly work.

- Jeff Prosise

Page 12: Unindented Code Cannot Possibly Work!

#DCAEC12#DCAEC12

Page 13: Unindented Code Cannot Possibly Work!

#DCAEC12#DCAEC12

Success is dependent on people, process, technology – in that order.

- Jeff Gallimore

Page 14: Unindented Code Cannot Possibly Work!

#DCAEC12

I - Passion

#DCAEC12

Page 15: Unindented Code Cannot Possibly Work!

#DCAEC12

I - Passion

#DCAEC12

Page 16: Unindented Code Cannot Possibly Work!

#DCAEC12

II – Communication

Verbal

Written

#DCAEC12

Page 17: Unindented Code Cannot Possibly Work!

#DCAEC12

II – Communication

#DCAEC12

Page 18: Unindented Code Cannot Possibly Work!

#DCAEC12#DCAEC12

Any fool can write code that a computer can understand.

Good programmers write code that humans can understand.

- Martin Fowler

Page 19: Unindented Code Cannot Possibly Work!

#DCAEC12

Does This Code Work?

If (productNames.Count > 0) Then lblProductName1.Text = productNames(0) lblProductName1.Visible = True End If If (productNames.Count > 1) Then lblProductName2.Text = productNames(1) lblProductName2.Visible = True End If . . . If (productNames.Count > 98) Then lblProductName99.Text = productNames(98) lblProductName99.Visible = True End If

Page 20: Unindented Code Cannot Possibly Work!

#DCAEC12

Does This Code Work?

SELECT a.CustomerName AS a, b.Address1 AS b, b.City AS c, b.PostalCode AS d, c.OrderNumber AS e FROM Customers a INNER JOIN Addresses b ON b.AddressId = a.AddressId INNER JOIN Orders c ON c.CustomerId = a.CustomerId WHERE c.IsProcessed = 0

Page 21: Unindented Code Cannot Possibly Work!

#DCAEC12

Does This Code Work?

// increment j i++;

Page 22: Unindented Code Cannot Possibly Work!

#DCAEC12

Does This Code Work?

string iCustnm; iCustnm = "644"; if (Cust.Has_Orders(iCustnm)) processOrders(iCustnm); else wiatforOrdersw(iCustnm); Display_Customer_Orders(iCustnm.ToString());

Page 23: Unindented Code Cannot Possibly Work!

#DCAEC12

III – Tools & Techniques

Page 24: Unindented Code Cannot Possibly Work!

#DCAEC12#DCAEC12

Skynet became self-aware.

- The Terminator

Page 25: Unindented Code Cannot Possibly Work!

#DCAEC12

Know Your Tools!

// Doug H. - 12/11/2010 - Bug 2733 // Rachel G. - 11/17/2010 - Bug 2544 // Doug H. - 11/11/2010 - Bug 2211 // Doug H. - 10/29/2010 - Bug 2211 // Howard W. - 8/6/2010 - Bug 2099 // Norm P. - 4/11/2010 - Bug 1556 // Doug H. - 1/14/2010 - Bug 1444 ProcessPayment(payment);

Page 26: Unindented Code Cannot Possibly Work!

#DCAEC12

Know Your Tools!

/* * * Edited by Doug H. * Thursday 3:45 p.m. * Outside Temperature 38°F * I live at 65 Main Street. * I wish I was on vacation. I have 6 days of vacation left. * */

Page 27: Unindented Code Cannot Possibly Work!

#DCAEC12#DCAEC12

CuStOmErADDRESSid

Page 28: Unindented Code Cannot Possibly Work!

#DCAEC12

III – Tools & Techniques

Know Your Tools

Think About Presentation

#DCAEC12

Page 29: Unindented Code Cannot Possibly Work!

#DCAEC12

Page 30: Unindented Code Cannot Possibly Work!

#DCAEC12

Page 31: Unindented Code Cannot Possibly Work!

#DCAEC12

You’re Surrounded!

Think of something you think is poorly designed.

Share with your group.

Page 32: Unindented Code Cannot Possibly Work!

#DCAEC12

Pick a group representative.

Share with the whole room.

We’re Surrounded!

Page 33: Unindented Code Cannot Possibly Work!

#DCAEC12

Page 34: Unindented Code Cannot Possibly Work!

#DCAEC12#DCAEC12

Page 35: Unindented Code Cannot Possibly Work!

#DCAEC12#DCAEC12

Attractive things work better.

- Donald A. Norman

Page 36: Unindented Code Cannot Possibly Work!

#DCAEC12

Know Your Patterns

Page 37: Unindented Code Cannot Possibly Work!

#DCAEC12

Know Your Patterns

Page 38: Unindented Code Cannot Possibly Work!

#DCAEC12

Know Your Patterns

Page 39: Unindented Code Cannot Possibly Work!

#DCAEC12

Know Your Patterns

Page 40: Unindented Code Cannot Possibly Work!

#DCAEC12

Know Your Patterns

Page 41: Unindented Code Cannot Possibly Work!

#DCAEC12

Know Your Patterns

Page 42: Unindented Code Cannot Possibly Work!

#DCAEC12

You are confirmed on United Airlines flight 2049, departing from Washington-Dulles Airport at 10:00 a.m. on Friday, December 7, 2012 and arriving at Seattle-Tacoma International Airport at 3:00 p.m.

Know Your Patterns

United Flight 2049Washington-Dulles to Seattle-Tacoma

Departs: Fri 12/7 10:00 AMArrives: Fri 12/7 3:00 PM

Page 43: Unindented Code Cannot Possibly Work!

#DCAEC12

Putting It All Together…

Page 44: Unindented Code Cannot Possibly Work!

#DCAEC12

Reading List

Page 45: Unindented Code Cannot Possibly Work!

#DCAEC12

Reading List

Page 46: Unindented Code Cannot Possibly Work!

#DCAEC12#DCAEC12

What do you think about when you hear the term legacy code?

… the sort of code that you just wish would die.

- Michael Feathers

Page 47: Unindented Code Cannot Possibly Work!

#DCAEC12

About Me

NAME: Ed Buhain

COMPANY: Excella Consulting

EMAIL: [email protected]

TWITTER: @buhain

BLOG: blog.buhain.com