SlideShare a Scribd company logo
1 of 21
Refactoring: Legacy The True Hacker's Guide To The Legacy
What is... ,[object Object]
Mature projects, optimization required.
Die hard, nobody knows why it is still alive.
Market victim, nobody wants this sh%t anymore.
Problem child, nobody loves it.
Every project in active long term support.,[object Object]
Low quality designed projects.
Small projects.
Every project you don't understand.,[object Object]
Developers who want refactor it.
A customer eager to pay for it.
RegEx
Advanced File Manager
Perfect IDE
Open mind – for everything else and many more,[object Object]
Migration #2: IoC (DI) FTW public class BlockDefService {     private static Logger logger = Logger.getLogger(BlockDefService.class);     public static final int MIN_DURATION = 4;     public static List<BlockDef> getBlockDefList(final BlockDefParamsparams) {         return BlockDefQueries.getBlockDefList(params);     }     public staticBlockDefloadBlockDef(final Long blockDefId) {         return BlockDefQueries.loadBlockDef(blockDefId);     }     public static void deleteBlockDef(final Long blockDefId) throws PartyException { 	…   } public class BlockDefBusiness {     public static final int MIN_DURATION = 4;     private static final Logger LOG = Logger.getLogger(BlockDefBusiness.class);     private PartyDaopartyDao;     private BlockDefDaoblockDefDao;     private PartyRoleDaopartyRoleDao;     public List<BlockDef> getBlockDefList(GregorianCalendarcurrentDay, Long partyId) {         return blockDefDao.getBlockDefList(currentDay, partyId);     }     public BlockDefloadBlockDef(Long blockDefId) {         return blockDefDao.loadBlockDef(blockDefId);     }     public void deleteBlockDef(Long blockDefId) throws PartyException { 	…     }
Migration #3: AOP driven ActionForward forward = null; try { 	// updateScreenCode(request); 	if (isTransactionable()) { TransactionManager.beginTransaction(); 	} forward = executeAction(mapping, form, req, res); 	if (isTransactionable()) { TransactionManager.commit(); 	} } catch (NullPointerException e) {// TODO It is not good LOG.error("NPE error in the action", e); 	forward = mapping.findForward(SYSTEM_ERROR); } catch (ModuleException e) { LOG.error(e.getMessage(), e); 	throw e; } catch (BusinessException e) { LOG.error(e.getMessage(), e); 	throw e; } catch (Throwable e) { LOG.error("Error in the action", e); 	forward = mapping.findForward(SYSTEM_ERROR); } ActionForward forward = executeAction(mapping, form, req, res); … <bean id="failAdvice" class="eterra.sr.service.FailAdvice“/> <tx:advice id=“interceptor" transaction-manager="trManager">     <tx:attributes>         <tx:method name="save*" propagation="REQUIRED"/>         <tx:method name="load*" propagation="REQUIRED"/>         <tx:method name="do*" propagation="REQUIRED"/>         <tx:method name="get*" propagation="SUPPORTS" read-only="true"/>     </tx:attributes> </tx:advice> <aop:config>     <aop:pointcut id=“actionClasses" expression=“…"/>     <aop:advisor advice-ref=“interceptor" pointcut-ref=“actionClasses" order="10"/>     <aop:aspect ref="failAdvice" order="1">         <aop:around method="aroundTransactional" pointcut-ref=“actionClasses"/>     </aop:aspect> </aop:config>
Migration #4: Update libraries Pros: ,[object Object]
Newer versions have better different integration options.
Newer versions can provide richer API sufficient to compete task better/faster/easier.Cons: ,[object Object],[object Object]

More Related Content

What's hot

What's hot (20)

The Ring programming language version 1.7 book - Part 92 of 196
The Ring programming language version 1.7 book - Part 92 of 196The Ring programming language version 1.7 book - Part 92 of 196
The Ring programming language version 1.7 book - Part 92 of 196
 
Kotlin meets Gadsu
Kotlin meets GadsuKotlin meets Gadsu
Kotlin meets Gadsu
 
The Ring programming language version 1.5.2 book - Part 176 of 181
The Ring programming language version 1.5.2 book - Part 176 of 181The Ring programming language version 1.5.2 book - Part 176 of 181
The Ring programming language version 1.5.2 book - Part 176 of 181
 
Javantura v2 - All Together Now - making Groovy and Scala sing together - Din...
Javantura v2 - All Together Now - making Groovy and Scala sing together - Din...Javantura v2 - All Together Now - making Groovy and Scala sing together - Din...
Javantura v2 - All Together Now - making Groovy and Scala sing together - Din...
 
Clean code slide
Clean code slideClean code slide
Clean code slide
 
Clean Code Development
Clean Code DevelopmentClean Code Development
Clean Code Development
 
Javantura v2 - Making Java web-apps Groovy - Franjo Žilić
Javantura v2 - Making Java web-apps Groovy - Franjo ŽilićJavantura v2 - Making Java web-apps Groovy - Franjo Žilić
Javantura v2 - Making Java web-apps Groovy - Franjo Žilić
 
The Ring programming language version 1.6 book - Part 184 of 189
The Ring programming language version 1.6 book - Part 184 of 189The Ring programming language version 1.6 book - Part 184 of 189
The Ring programming language version 1.6 book - Part 184 of 189
 
Kotlin 101 for Java Developers
Kotlin 101 for Java DevelopersKotlin 101 for Java Developers
Kotlin 101 for Java Developers
 
PVS-Studio in 2021 - Error Examples
PVS-Studio in 2021 - Error ExamplesPVS-Studio in 2021 - Error Examples
PVS-Studio in 2021 - Error Examples
 
The Ring programming language version 1.10 book - Part 102 of 212
The Ring programming language version 1.10 book - Part 102 of 212The Ring programming language version 1.10 book - Part 102 of 212
The Ring programming language version 1.10 book - Part 102 of 212
 
clean code book summary - uncle bob - English version
clean code book summary - uncle bob - English versionclean code book summary - uncle bob - English version
clean code book summary - uncle bob - English version
 
Clean code
Clean codeClean code
Clean code
 
How Data Flow analysis works in a static code analyzer
How Data Flow analysis works in a static code analyzerHow Data Flow analysis works in a static code analyzer
How Data Flow analysis works in a static code analyzer
 
Lift off with Groovy 2 at JavaOne 2013
Lift off with Groovy 2 at JavaOne 2013Lift off with Groovy 2 at JavaOne 2013
Lift off with Groovy 2 at JavaOne 2013
 
The Ring programming language version 1.5.4 book - Part 180 of 185
The Ring programming language version 1.5.4 book - Part 180 of 185The Ring programming language version 1.5.4 book - Part 180 of 185
The Ring programming language version 1.5.4 book - Part 180 of 185
 
Static code analysis: what? how? why?
Static code analysis: what? how? why?Static code analysis: what? how? why?
Static code analysis: what? how? why?
 
JavaScript Common Mistake
JavaScript Common MistakeJavaScript Common Mistake
JavaScript Common Mistake
 
Writing clean code
Writing clean codeWriting clean code
Writing clean code
 
Groovy Ast Transformations (greach)
Groovy Ast Transformations (greach)Groovy Ast Transformations (greach)
Groovy Ast Transformations (greach)
 

Similar to Club of anonimous developers "Refactoring: Legacy code"

Lecture 5: Functional Programming
Lecture 5: Functional ProgrammingLecture 5: Functional Programming
Lecture 5: Functional Programming
Eelco Visser
 

Similar to Club of anonimous developers "Refactoring: Legacy code" (20)

Legacy projects: how to win the race
Legacy projects: how to win the raceLegacy projects: how to win the race
Legacy projects: how to win the race
 
Javascript
JavascriptJavascript
Javascript
 
DPC 2019, Amsterdam: Beyond design patterns and principles - writing good OO ...
DPC 2019, Amsterdam: Beyond design patterns and principles - writing good OO ...DPC 2019, Amsterdam: Beyond design patterns and principles - writing good OO ...
DPC 2019, Amsterdam: Beyond design patterns and principles - writing good OO ...
 
JDD 2016 - Sebastian Malaca - You Dont Need Unit Tests
JDD 2016 - Sebastian Malaca - You Dont Need Unit TestsJDD 2016 - Sebastian Malaca - You Dont Need Unit Tests
JDD 2016 - Sebastian Malaca - You Dont Need Unit Tests
 
HashiCorp Vault Plugin Infrastructure
HashiCorp Vault Plugin InfrastructureHashiCorp Vault Plugin Infrastructure
HashiCorp Vault Plugin Infrastructure
 
Clean code and Code Smells
Clean code and Code SmellsClean code and Code Smells
Clean code and Code Smells
 
API first with Swagger and Scala by Slava Schmidt
API first with Swagger and Scala by  Slava SchmidtAPI first with Swagger and Scala by  Slava Schmidt
API first with Swagger and Scala by Slava Schmidt
 
Refactoring
RefactoringRefactoring
Refactoring
 
Scala for Java Developers
Scala for Java DevelopersScala for Java Developers
Scala for Java Developers
 
Mixing functional and object oriented approaches to programming in C#
Mixing functional and object oriented approaches to programming in C#Mixing functional and object oriented approaches to programming in C#
Mixing functional and object oriented approaches to programming in C#
 
Type script, for dummies
Type script, for dummiesType script, for dummies
Type script, for dummies
 
Legacy projects: how to win the race
Legacy projects: how to win the raceLegacy projects: how to win the race
Legacy projects: how to win the race
 
Apache Spark - Basics of RDD & RDD Operations | Big Data Hadoop Spark Tutoria...
Apache Spark - Basics of RDD & RDD Operations | Big Data Hadoop Spark Tutoria...Apache Spark - Basics of RDD & RDD Operations | Big Data Hadoop Spark Tutoria...
Apache Spark - Basics of RDD & RDD Operations | Big Data Hadoop Spark Tutoria...
 
Code is not text! How graph technologies can help us to understand our code b...
Code is not text! How graph technologies can help us to understand our code b...Code is not text! How graph technologies can help us to understand our code b...
Code is not text! How graph technologies can help us to understand our code b...
 
Effective Java with Groovy & Kotlin How Languages Influence Adoption of Good ...
Effective Java with Groovy & Kotlin How Languages Influence Adoption of Good ...Effective Java with Groovy & Kotlin How Languages Influence Adoption of Good ...
Effective Java with Groovy & Kotlin How Languages Influence Adoption of Good ...
 
CS101- Introduction to Computing- Lecture 29
CS101- Introduction to Computing- Lecture 29CS101- Introduction to Computing- Lecture 29
CS101- Introduction to Computing- Lecture 29
 
GDSC Flutter Forward Workshop.pptx
GDSC Flutter Forward Workshop.pptxGDSC Flutter Forward Workshop.pptx
GDSC Flutter Forward Workshop.pptx
 
Core java
Core javaCore java
Core java
 
Lecture 5: Functional Programming
Lecture 5: Functional ProgrammingLecture 5: Functional Programming
Lecture 5: Functional Programming
 
02 functions, variables, basic input and output of c++
02   functions, variables, basic input and output of c++02   functions, variables, basic input and output of c++
02 functions, variables, basic input and output of c++
 

More from Victor_Cr

Jboss drools expert (ru)
Jboss drools expert (ru)Jboss drools expert (ru)
Jboss drools expert (ru)
Victor_Cr
 
JEEConf JBoss Drools
JEEConf JBoss DroolsJEEConf JBoss Drools
JEEConf JBoss Drools
Victor_Cr
 
JBoss Drools
JBoss DroolsJBoss Drools
JBoss Drools
Victor_Cr
 

More from Victor_Cr (14)

Data Wars: The Bloody Enterprise strikes back
Data Wars: The Bloody Enterprise strikes backData Wars: The Bloody Enterprise strikes back
Data Wars: The Bloody Enterprise strikes back
 
Data Wars: The Bloody Enterprise strikes back
Data Wars: The Bloody Enterprise strikes backData Wars: The Bloody Enterprise strikes back
Data Wars: The Bloody Enterprise strikes back
 
Type War: Weak vs Strong [JEEConf 2016]
Type War: Weak vs Strong [JEEConf 2016]Type War: Weak vs Strong [JEEConf 2016]
Type War: Weak vs Strong [JEEConf 2016]
 
Types: Weak/Duck/Optional vs Strong/Strict. Let the War Begin!
Types: Weak/Duck/Optional vs Strong/Strict. Let the War Begin!Types: Weak/Duck/Optional vs Strong/Strict. Let the War Begin!
Types: Weak/Duck/Optional vs Strong/Strict. Let the War Begin!
 
Types: Weak/Duck/Optional vs Strong/Strict. Let the War Begin!
Types: Weak/Duck/Optional vs Strong/Strict. Let the War Begin!Types: Weak/Duck/Optional vs Strong/Strict. Let the War Begin!
Types: Weak/Duck/Optional vs Strong/Strict. Let the War Begin!
 
Legacy: как победить в гонке (Joker)
Legacy: как победить в гонке (Joker)Legacy: как победить в гонке (Joker)
Legacy: как победить в гонке (Joker)
 
Web-application I’ve always dreamt of (Kharkiv)
Web-application I’ve always dreamt of (Kharkiv)Web-application I’ve always dreamt of (Kharkiv)
Web-application I’ve always dreamt of (Kharkiv)
 
Web application I have always dreamt of (Lviv)
Web application I have always dreamt of (Lviv)Web application I have always dreamt of (Lviv)
Web application I have always dreamt of (Lviv)
 
Web application I have always dreamt of
Web application I have always dreamt ofWeb application I have always dreamt of
Web application I have always dreamt of
 
Jboss drools expert (ru)
Jboss drools expert (ru)Jboss drools expert (ru)
Jboss drools expert (ru)
 
JEEConf WEB
JEEConf WEBJEEConf WEB
JEEConf WEB
 
JEEConf JBoss Drools
JEEConf JBoss DroolsJEEConf JBoss Drools
JEEConf JBoss Drools
 
JBoss Drools
JBoss DroolsJBoss Drools
JBoss Drools
 
XPDays Ukraine: Legacy
XPDays Ukraine: LegacyXPDays Ukraine: Legacy
XPDays Ukraine: Legacy
 

Recently uploaded

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Recently uploaded (20)

CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 

Club of anonimous developers "Refactoring: Legacy code"

  • 1. Refactoring: Legacy The True Hacker's Guide To The Legacy
  • 2.
  • 4. Die hard, nobody knows why it is still alive.
  • 5. Market victim, nobody wants this sh%t anymore.
  • 7.
  • 10.
  • 11. Developers who want refactor it.
  • 12. A customer eager to pay for it.
  • 13. RegEx
  • 16.
  • 17. Migration #2: IoC (DI) FTW public class BlockDefService { private static Logger logger = Logger.getLogger(BlockDefService.class); public static final int MIN_DURATION = 4; public static List<BlockDef> getBlockDefList(final BlockDefParamsparams) { return BlockDefQueries.getBlockDefList(params); } public staticBlockDefloadBlockDef(final Long blockDefId) { return BlockDefQueries.loadBlockDef(blockDefId); } public static void deleteBlockDef(final Long blockDefId) throws PartyException { … } public class BlockDefBusiness { public static final int MIN_DURATION = 4; private static final Logger LOG = Logger.getLogger(BlockDefBusiness.class); private PartyDaopartyDao; private BlockDefDaoblockDefDao; private PartyRoleDaopartyRoleDao; public List<BlockDef> getBlockDefList(GregorianCalendarcurrentDay, Long partyId) { return blockDefDao.getBlockDefList(currentDay, partyId); } public BlockDefloadBlockDef(Long blockDefId) { return blockDefDao.loadBlockDef(blockDefId); } public void deleteBlockDef(Long blockDefId) throws PartyException { … }
  • 18. Migration #3: AOP driven ActionForward forward = null; try { // updateScreenCode(request); if (isTransactionable()) { TransactionManager.beginTransaction(); } forward = executeAction(mapping, form, req, res); if (isTransactionable()) { TransactionManager.commit(); } } catch (NullPointerException e) {// TODO It is not good LOG.error("NPE error in the action", e); forward = mapping.findForward(SYSTEM_ERROR); } catch (ModuleException e) { LOG.error(e.getMessage(), e); throw e; } catch (BusinessException e) { LOG.error(e.getMessage(), e); throw e; } catch (Throwable e) { LOG.error("Error in the action", e); forward = mapping.findForward(SYSTEM_ERROR); } ActionForward forward = executeAction(mapping, form, req, res); … <bean id="failAdvice" class="eterra.sr.service.FailAdvice“/> <tx:advice id=“interceptor" transaction-manager="trManager"> <tx:attributes> <tx:method name="save*" propagation="REQUIRED"/> <tx:method name="load*" propagation="REQUIRED"/> <tx:method name="do*" propagation="REQUIRED"/> <tx:method name="get*" propagation="SUPPORTS" read-only="true"/> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut id=“actionClasses" expression=“…"/> <aop:advisor advice-ref=“interceptor" pointcut-ref=“actionClasses" order="10"/> <aop:aspect ref="failAdvice" order="1"> <aop:around method="aroundTransactional" pointcut-ref=“actionClasses"/> </aop:aspect> </aop:config>
  • 19.
  • 20. Newer versions have better different integration options.
  • 21.
  • 22.
  • 23. How-to integrate a DI container.
  • 25. How-to find and eliminate unreadable code.
  • 26.
  • 27. Write appropriate regular expression to remove all except method declarations.
  • 28. Declare result as interfaces.
  • 29. Create delegate implementations which calls old “procedural” classes.
  • 30.
  • 31.
  • 32.
  • 33. New code must not use the same bad approach as “the legacy” part or it never ends.
  • 34.
  • 35. If it looks like “aspect”, it is “aspect” with 95% probability, trust me.
  • 36. Annotations with AOP have incredible power.
  • 37.
  • 38.
  • 39. FindBugs, CPD, PMD, FxCop etc.
  • 40. Scripts and configuration files are the most dangerous.
  • 41. Pair programming is very effective during project start.
  • 42.