inheriting code

31
Inheriting Code Anthony Eden Tuesday, June 8, 2010

Upload: anthony-eden

Post on 28-Jan-2015

106 views

Category:

Technology


0 download

DESCRIPTION

It is inevitable that at some point in your career as a developer you will inherit code developed by others. Trying to understand code developed by someone else can often lead to stress and frustration, but it doesn't have to. This talk will provide you with tools and techniques to help understand and begin working with code from other developers quickly and easily.

TRANSCRIPT

Page 1: Inheriting Code

Inheriting Code

Anthony Eden

Tuesday, June 8, 2010

Page 2: Inheriting Code

Who are you?

Tuesday, June 8, 2010

Page 3: Inheriting Code

Explorer

Tuesday, June 8, 2010

You’ll need to be willing to travel down uncharted paths and create a map to find your way out.

Page 4: Inheriting Code

Historian

Tuesday, June 8, 2010

You’ll need to understand what got the code here.

Page 5: Inheriting Code

Forensic Analyst

Tuesday, June 8, 2010

You’ll need to understand the motives by looking at the crime scene.

Page 6: Inheriting Code

Psychic

Tuesday, June 8, 2010

You’ll need to read minds.

Page 7: Inheriting Code

Sadist

Tuesday, June 8, 2010

You’ll need to be able to hurt the code.

Page 8: Inheriting Code

MasochistTuesday, June 8, 2010

You’ll need to be able to withstand the pain that the code causes you.

Page 9: Inheriting Code

Prepare

Tuesday, June 8, 2010

Adjust your mode of thinking.

Page 10: Inheriting Code

Assume nothing

Tuesday, June 8, 2010

Page 11: Inheriting Code

You are not smarter, just different

Tuesday, June 8, 2010

Put yourself in the mind of the author. Keep an open mind about implementations that are different from how you might do it.Understand why they may have written code in the way they did.

Page 12: Inheriting Code

Learn

Tuesday, June 8, 2010

Page 13: Inheriting Code

Read

Tuesday, June 8, 2010

Read the codeRead the documentation

Page 14: Inheriting Code

Cause and Effect

Tuesday, June 8, 2010

What were the business needs that caused this code to be written?What other factors were present when the code was written?

Page 15: Inheriting Code

Find the dragons

Tuesday, June 8, 2010

What code was written to solve an immediate problem, but never refactored?What code was written to old APIs?What code was written in different styles by different developers?

Page 16: Inheriting Code

Act

Tuesday, June 8, 2010

Page 17: Inheriting Code

Resolve DependenciesTuesday, June 8, 2010

Page 18: Inheriting Code

Run the test suite

Tuesday, June 8, 2010

Page 19: Inheriting Code

Write tests where there are none

Tuesday, June 8, 2010

Top down approach with Cucumber.Bottom up approach with RSpec, Shoulda or plain Test::Unit.If tests are already written then start Regardless you’ll need both.

Page 20: Inheriting Code

Simplify complex code

Tuesday, June 8, 2010

When a test is written you can refactor it.

Page 21: Inheriting Code

Reduce

Tuesday, June 8, 2010

Reduce the amount of code.Remove unused methods and classes.Version control is your friend.

Page 22: Inheriting Code

Have a rollback strategy

Tuesday, June 8, 2010

You will misunderstand the purpose of some of the code.Be able to rollback easily.Version control is essential.Make small changes.

Page 23: Inheriting Code

Make small changes

Tuesday, June 8, 2010

Small changes are easier to fix.Small changes are easier to undo.

Page 24: Inheriting Code

CompartmentalizeTuesday, June 8, 2010

Break down monolithic code into smaller chunks.Break down large features into smaller ones.

Page 25: Inheriting Code

Protectthe data

Tuesday, June 8, 2010

Along with code you’ll be inheriting data.

Page 26: Inheriting Code

Write for maintainabilityTuesday, June 8, 2010

New features are always tested.

Page 27: Inheriting Code

Follow conventions

Tuesday, June 8, 2010

Rails conventions are your friend.

Page 28: Inheriting Code

Deploy Early, Deploy Often

Tuesday, June 8, 2010

Page 29: Inheriting Code

Build a better legacy

Tuesday, June 8, 2010

Page 30: Inheriting Code

Share knowledge

Tuesday, June 8, 2010

Pairing helps tremendously herePerform code reviews

Page 31: Inheriting Code

http://www.flickr.com/photos/natedreger/4272271989/http://www.flickr.com/photos/atelier_tee/212176187/

http://www.flickr.com/photos/h-k-d/3617751660/http://www.flickr.com/photos/vogelium/2623770180/

http://www.flickr.com/photos/9619972@N08/2636808004/http://www.flickr.com/photos/emeraldrose/3587025487/

http://www.flickr.com/photos/mcgraths/3248483447/http://www.flickr.com/photos/inhalingsounds/4444522392/http://www.flickr.com/photos/rossinabossio/289756071/

http://www.flickr.com/photos/wili/2628869994/http://www.flickr.com/photos/fofurasfelinas/2549402702/http://www.flickr.com/photos/ironrodart/4154904299/http://www.flickr.com/photos/myrmician/228790898/

http://www.flickr.com/photos/29487767@N02/3644730871/http://www.flickr.com/photos/teacherafael/2038442136/

http://www.flickr.com/photos/gamene/4015192611/http://www.flickr.com/photos/shewatchedthesky/2835193235/

http://www.flickr.com/photos/myreflex/180524429/http://www.flickr.com/photos/tzofia/202684786/

http://www.flickr.com/photos/capedcrusader/3713232485/http://www.flickr.com/photos/jaxxon/93296381/http://www.flickr.com/photos/jbird/19650368/

http://www.flickr.com/photos/joeharper/3872936498/http://www.flickr.com/photos/bassclarinetist/4448830860/

http://www.flickr.com/photos/winterofdiscontent/3301816514/http://www.flickr.com/photos/74274915@N00/3554610230/

http://www.flickr.com/photos/tal_axl/4297212753/http://www.flickr.com/photos/essjay/2397379457/

Tuesday, June 8, 2010