Sandro Mancuso – Testing and refactoring legacy code @ I T.A.K.E. Unconference 2013, Bucharest

5,605 views
5,745 views

Published on

Check out the video of the presentation: http://www.youtube.com/watch?v=WpKb1XqSiUs

Published in: Technology, Education
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
5,605
On SlideShare
0
From Embeds
0
Number of Embeds
11
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Sandro Mancuso – Testing and refactoring legacy code @ I T.A.K.E. Unconference 2013, Bucharest

  1. 1. Testing and Refactoring Legacy Code Sandro Mancuso @sandromancuso craftedsw.blogspot.com
  2. 2. What is this session about?
  3. 3. Business Requirements Imagine a social networking website for travellers • You need to be logged in to see the content • You need to be a friend to see someone else’s trips
  4. 4. Legacy Code Rules • You cannot change production code if not covered by tests – Just automated refactoring (via IDE) is allowed, in case it is needed for writing a test
  5. 5. Show me the code
  6. 6. Start refactoring from deepest to shortest branch Start testing from shortest to deepest branch Working with Legacy Code Tips
  7. 7. Trip Service - Problems TripService +findTripsByUser(User) : List<Trip> <<Singleton>> UserSession +getInstance() : UserSession +getLoggedUser() : User TripDAO +findTripsByUser(User) : List<Trip>
  8. 8. Let’s write some code
  9. 9. Start refactoring from deepest to shortest branch Start testing from shortest to deepest branch Working with Legacy Code Tips
  10. 10. Craftsmen at work • Write readable and maintainable code and tests – Code must express business rules • Strive for simplicity • Know your tools well (i.e. frameworks, shortcuts) • Work in small and safe increments – Commit often • Embrace changes, be brave • Boy scout rule / No broken windows
  11. 11. Thanks Sandro Mancuso @sandromancuso craftedsw.blogspot.com https://github.com/sandromancuso/trip-service-kata leanpub.com/socra

×