Working with legacy code

20
Working with legacy code GUNNAR PEIPMAN, ASP.NET/IIS MVP

Transcript of Working with legacy code

Page 1: Working with legacy code

Working with legacy codeGUNNAR PEIPMAN, ASP.NET/IIS MVP

Page 2: Working with legacy code

About me

Name: Gunnar Peipman

Job: Chief Everything Officer

Company: Peipman Consult Ltd

Hobbies: Coding, reading, travelling, beers

In family: boyfriend, step father and father

Animals: white fluffy bunny

Me & MS: ASP.NET/IIS MVP, blogger, speaker

Community: ENETA (www.eneta.ee)

http://weblogs.asp.net/gunnarpeipman/

E-mail: [email protected]

Page 3: Working with legacy code

Agenda

What is legacy code and where it comes from?

How to fight back?

Tools and techniques

Examples

Questions and answers

Page 4: Working with legacy code

Essentials of legacy code

Page 5: Working with legacy code

What is legacy code?

The code we already released to users

Code covered with no tests

Messy code

Page 6: Working with legacy code

LEGACY CODE

messy

confusingbad dependencies

hard to read spaghetti

untestable

ugly

don‘t touch it

in production

undocumented

tricky

problematic

just works

Page 7: Working with legacy code

Where legacy code comes from?

Death march projects Unskilled developers Impossible dead-lines Bleeding-edge technologies Complex technologies Silver-bullet tools Digital slavery

Page 8: Working with legacy code

Dynamics of legacy code

All problems happen every day with small steps under our own eyes

Page 9: Working with legacy code

War plan

Page 10: Working with legacy code

How to fight back?

Write readable code

Write testable code

Refactor

Avoid hacks

Look how others have solved similar problems

Study different patterns

Improve your coding skills

If you find mess then clean it up

Page 11: Working with legacy code

Process for single developers

Find mess

Investigate

RefactorRedesign

Validate

Page 12: Working with legacy code

Process for teams

Code review

Detect problems

Agree on solutions

Redesign code

Validate

Page 13: Working with legacy code

Winning the battle

Page 14: Working with legacy code

Refactoring

Refactoring - making changes that doesn’t change code functionality

Different tools provided by IDE-s

Page 15: Working with legacy code

Patterns

Design patterns

Unit testing patterns

Analysis patterns

Enterprise applications architecture patterns

Enterprise integration patterns

SOA patterns

Universal data models

Page 16: Working with legacy code

Testing

Unit tests

Integration tests

Stress tests

Performance tests

User Interface tests

Database tests

Acceptance tests

Tracer bullet tests

Page 17: Working with legacy code

Quality assurance

Automated and manual testing

Code reviews

Paired programming

Set up goals for developers

Page 18: Working with legacy code

Examples

Page 19: Working with legacy code

Thank you!

Page 20: Working with legacy code

Q&A