Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Improving Legacy Applications with Spring Marten Deinum, Consultant, Conspect Consulting & ICT @mdeinum
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 2 Marten Deinum Spring Community Rockstar @mdeinum | [email protected] § Father § Husband § Experienced Java/JEE Consultant § Pragmatist Author Open Source Enthusiast
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Legacy Software - History § JDK 1.0 was released in 1996 • ~ 20 years old § First JEE (or J2EE 1.2) released in 1999 • ~ 16 years old § J2EE Design and Development by Rod Johnson in 2002 • Led to the Spring Framework we know today § Spring 1.0 was released in 2004 • ~ 12 years old § A lot of application have been build in that time period • Some of those still exist • Code is still being used 3
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Legacy Software § Has proven itself (battle tested) § Has proven business value § It exists and we have to deal with it • Ignore • Hide • Full Rebuild • Incremental Redesign 5
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Legacy Software - Architecture 6
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Legacy Software - Architecture 7 Domain Presentation Service Data Access Presentation Service Data Access Domain DTO
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Legacy Software - Architecture 8 Presentation Service Data Access Presentation Service Data Access Presentation Service Data Access
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Legacy Software - Architecture 9
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Legacy Software - How to Improve 11
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 12 Legacy Software - Structured Monolith “If you can't build a structured monolith, what makes you think microservices are the answer? Simon Brown
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 13 Legacy Software - Structured Monolith
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Legacy Software - Structured Monolith § Write integration tests! 14
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Legacy Software - Structured Monolith § Write integration tests! § Single Responsibility Principle • A [class|component|service] should have one, and only one, reason to change. • Classes that change together are packaged together. • Classes that are used together are packaged together. 16
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Legacy Software - Structured Monolith § Write integration tests! § Single Responsibility Principle • A [class|component|service] should have one, and only one, reason to change. • Classes that change together are packaged together. • Classes that are used together are packaged together. § Protect your Internals § Use package protected classes § Expose only the public API 17
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Legacy Software - Structured Monolith 18 Integration Core User Event web security ws
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Legacy Software - Structured Monolith § Write integration tests! § Single Responsibility Principle § Protect your internals § Decouple using events § Use the right abstractions and framework features 20
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Legacy Software - Structured Monolith § Write integration tests! § Single Responsibility Principle § Protect your internals § Decouple using events § Spring 4.2 has some nice improvements in this area https://spring.io/blog/2015/02/11/better-application-events-in-spring- framework-4-2 § Use the right abstractions and framework features 22
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Legacy Software - Independent Services 23 "Physalia physalis, Tayrona national park, Colombia" by Biusch - Own work.
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Legacy Software - Lessons Learned § Have a plan and prioritize § Use automated tests § Take small steps § Upgrading Spring might not be as hard as you think § Upgrading a JDK might not be as hard as you think § Know your frameworks / libraries § Use the right abstractions 26
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 28 Learn More. Stay Connected. Twitter: twitter.com/mdeinum YouTube: spring.io/video LinkedIn: nl.linkedin.com/in/mdeinum GitHub: github.com/mdeinum