The Joys and Pains of a Long Lived Codebase Jeremy D. Miller - - PowerPoint PPT Presentation

the joys and pains of a long lived codebase
SMART_READER_LITE
LIVE PREVIEW

The Joys and Pains of a Long Lived Codebase Jeremy D. Miller - - PowerPoint PPT Presentation

The Joys and Pains of a Long Lived Codebase Jeremy D. Miller November 20 th , 2008 About Me Chief Software Architect at Dovetail Software in Austin, TX Author of StructureMap http://structuremap.sourceforge.net The Shade Tree


slide-1
SLIDE 1

The Joys and Pains of a Long Lived Codebase

Jeremy D. Miller November 20th, 2008

slide-2
SLIDE 2

About Me

Chief Software Architect at Dovetail Software in Austin, TX Author of StructureMap

♦ http://structuremap.sourceforge.net

“The Shade Tree Developer” “The Shade Tree Developer”

♦ http://codebetter.com/blogs/jeremy.miller

jeremydmiller@yahoo.com

slide-3
SLIDE 3

What is StructureMap?

Inversion of Control / Dependency Injection tool for .Net Open Source under the Apache 2.0 license I’m the primary author …this isn’t really about StructureMap itself

slide-4
SLIDE 4

The Journey So Far

Recovering data centric VB6 developer to… StructureMap was originally released in 2004 TDD was new in .Net circles .Net 1.1 to .Net 2.0 to .Net 3.5 The “Python 3000” Release in 2008 The “Python 3000” Release in 2008

slide-5
SLIDE 5

What has Changed?

Lower tolerance for ceremony Programmatic configuration is now favored over Xml configuration More complicated usage

♦ Composite configuration ♦ Composite configuration ♦ Interception

Convention over Configuration Explicit Configuration vs. Just Let it Work Language innovation

slide-6
SLIDE 6

What Have I Learned?

Solid design in the small is crucial To organize and structure by behavior Automated test coverage isn’t automatically effective Some nasty lessons about creating API’s for other developers developers

slide-7
SLIDE 7

Don’t Repeat Yourself

It’s 2005, and Generics are all the rage in .Net Wouldn’t it be nice if StructureMap could support open generic types… Lesson Learned: Even innocuous looking duplication can be harmful

slide-8
SLIDE 8

Encapsulation is Key

slide-9
SLIDE 9

Vile, Evil Code

public class ClassWithFoos { private readonly IDictionary<string, Foo> _foos = new Dictionary<string, Foo>(); public IDictionary<string, Foo> Foos { get { return _foos; } } }

slide-10
SLIDE 10

Keep the Code Limber

Watch for similar code Use static code analysis as another pair of eyes Reduce the size of the codebase

slide-11
SLIDE 11

Better Abstractions

“Noun” based design is naïve Design abstractions by responsibilities and roles Use object role stereotypes

slide-12
SLIDE 12

“The Great Refactoring of Aught Eight”

Before InstanceManager InstanceFactory InstanceMemento After Container InstanceFactory (simpler) Instance InstanceMemento Instance BuildSession PipelineGraph BuildPolicy

slide-13
SLIDE 13

Test Driven Development allows for modifiability…

…if done well

slide-14
SLIDE 14

Organizing Tests

1 Concrete Class == 1 TestFixture (Not!) TestFixture per Feature Arriving at Behavior Driven Development

♦ Number of Assertions per Test

Pay attention to the “language” of tests

♦ Pay attention to the “language” of tests ♦ Emphasize scenarios over units of code ♦ Test what you’re testing

slide-15
SLIDE 15

Test Input

Ideally, tests should be self-contained Use meaningful test data Watch the Expensive Test Setup Smell Invest in ObjectMothers or Test Data Builders Be extremely cautious in reusing test data across multiple Be extremely cautious in reusing test data across multiple tests

slide-16
SLIDE 16

Building Configuration Intensive Frameworks

Isolate functionality from configuration Isolate the user from framework internals Fail Fast Diagnostics are Important

slide-17
SLIDE 17

Crafting Good API’s

Essence vs. Ceremony The Pit of Success Consistency Predictability Discoverability Discoverability Readability / Understandability

slide-18
SLIDE 18

Takeaways

Keep your code clean Make sure your abstractions match reality, and reality changes over time Minimize ceremony Test behaviors, not implementation details Test behaviors, not implementation details Good tests are readable tests