SlideShare a Scribd company logo
Refactoring: LegacyThe True Hacker's Guide To The Legacy
What is...Very old projects, had been written long long ago.
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.What is usually NOT...Badly written projects which are not in production.
Low quality designed projects.
Small projects.
Every project you don't understand.What do we need?Legacy project.
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 moreMigration #1: from TOM to POM<target name="generate.libs"		depends="init"		unless="ignore.generate.libdep"		description="Generate library dependencies">	<mkdir dir="${build}/svn-checkout"/>	<!-- Get here the sources and build the jar -->	<ant inheritAll="false"antfile="${build.config.dir}/svnsupport.xml"		 target="checkout">		<property name="svn.username" value="${svn.username}"/>		<property name="svn.password" value="${svn.password}"/>		<property name="svn.url" value="${svn.url.eterracore}"/>		<property name="svn.target.dir" value="${build}/svn-checkout"/>	</ant>	<!-- Run the ant into the checkout dir -->	<ant inheritAll="false"antfile="${build}/svn-checkout/build.xml"		 target="jar">	</ant>	<copy todir="${libdep.dir}">		<fileset dir="${build}/svn-checkout/build/">			<include name="*.jar"/>		</fileset>	</copy></target><modules>    <module>core</module>    <module>demo</module>    <module>noncla</module>    <module>protocol/bayeux</module>    <module>protocol/dwrp</module>    <module>protocol/json</module>    <module>serverside/guice</module>    <module>serverside/hibernate</module>    <module>serverside/hibernate2</module>    <module>serverside/spring</module>    <module>serverside/struts</module>    <module>serverside/various</module>    <module>serverside/webwork</module>    <module>ui/dojo</module>    <module>ui/dwr</module>    <module>ui/gi</module>    <module>ui/jaxer</module>    <module>ui/scriptaculous</module>  </modules>
Migration #2: IoC (DI) FTWpublic 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 drivenActionForward 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 goodLOG.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 librariesPros:Newer versions usually better optimized so you will get performance for free.
Newer versions have better different integration options.
Newer versions can provide richer API sufficient to compete task better/faster/easier.Cons:Newer versions can be incompatible with: JDK, other libraries, old configuration files etc.Migration #5: Code cleanupCollections.sort(list, new Comparator() { public int compare(Object o1, Object o2) {int value;                Offer offer1 = (Offer) ((TradeConfirmation) o1).getOffer();                Offer offer2 = (Offer) ((TradeConfirmation) o2).getOffer();                if (offer1.getTradingInterval() < offer2.getTradingInterval()) {                    value = -1;                } else {                    if (offer1.getTradingInterval() == offer2.getTradingInterval()) {                        if (offer1.getType() < offer2.getType()) {                            value = -1;                        } else {                            if (offer1.getType() == offer2.getType()) {PartyDef party1 = offer1.getParty().getEffectiveParty(deliveryD);PartyDef party2 = offer2.getParty().getEffectiveParty(deliveryD);                                if (party1.getName().compareTo(party2.getName()) < 0) {                                    value = -1;                                } else {                                    if (party1.getName().compareTo(party2.getName()) == 0) {                                        if (offer1.getTradingZone().getEffectiveTradingDef(deliveryD).getIdentification().compareTo(…) < 0) {                                            value = -1;                                        } else {                                            if (offer1.getTradingZone().getEffectiveTradingDef(deliveryD).getIdentification(…)) == 0) {                                                value = 0;                                            } else {                                                value = 1;                                            }                                        }                                    } else {                                        value = 1;                                    }                                }                            } else {                                value = 1;                            }                        }                    } else {                        value = 1;                    }                }                return value;            }        });

More Related Content

What's hot (18)

PDF
The Ring programming language version 1.7 book - Part 92 of 196
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.2 book - Part 176 of 181
Mahmoud Samir Fayed
 
PDF
Javantura v2 - All Together Now - making Groovy and Scala sing together - Din...
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
PPTX
Clean code slide
Anh Huan Miu
 
PPTX
Clean Code Development
Peter Gfader
 
PDF
Javantura v2 - Making Java web-apps Groovy - Franjo Žilić
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
PDF
The Ring programming language version 1.6 book - Part 184 of 189
Mahmoud Samir Fayed
 
PDF
PVS-Studio in 2021 - Error Examples
Andrey Karpov
 
PDF
The Ring programming language version 1.10 book - Part 102 of 212
Mahmoud Samir Fayed
 
PPTX
clean code book summary - uncle bob - English version
saber tabatabaee
 
PPTX
Clean code
ifnu bima
 
PPTX
How Data Flow analysis works in a static code analyzer
Andrey Karpov
 
PDF
Lift off with Groovy 2 at JavaOne 2013
Guillaume Laforge
 
PDF
The Ring programming language version 1.5.4 book - Part 180 of 185
Mahmoud Samir Fayed
 
PPTX
Static code analysis: what? how? why?
Andrey Karpov
 
PPTX
JavaScript Common Mistake
Jai_Patel
 
PDF
Writing clean code
Angel Garcia Olloqui
 
ODP
Groovy Ast Transformations (greach)
HamletDRC
 
The Ring programming language version 1.7 book - Part 92 of 196
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.2 book - Part 176 of 181
Mahmoud Samir Fayed
 
Javantura v2 - All Together Now - making Groovy and Scala sing together - Din...
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
Clean code slide
Anh Huan Miu
 
Clean Code Development
Peter Gfader
 
Javantura v2 - Making Java web-apps Groovy - Franjo Žilić
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
The Ring programming language version 1.6 book - Part 184 of 189
Mahmoud Samir Fayed
 
PVS-Studio in 2021 - Error Examples
Andrey Karpov
 
The Ring programming language version 1.10 book - Part 102 of 212
Mahmoud Samir Fayed
 
clean code book summary - uncle bob - English version
saber tabatabaee
 
Clean code
ifnu bima
 
How Data Flow analysis works in a static code analyzer
Andrey Karpov
 
Lift off with Groovy 2 at JavaOne 2013
Guillaume Laforge
 
The Ring programming language version 1.5.4 book - Part 180 of 185
Mahmoud Samir Fayed
 
Static code analysis: what? how? why?
Andrey Karpov
 
JavaScript Common Mistake
Jai_Patel
 
Writing clean code
Angel Garcia Olloqui
 
Groovy Ast Transformations (greach)
HamletDRC
 

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

ODP
Simple design/programming nuggets
Vivek Singh
 
PPTX
Refactoring legacy code: step-by-step examples
Endava
 
KEY
SOLID Principles
Chris Weldon
 
PDF
Improving application design with a rich domain model (springone 2007)
Chris Richardson
 
PPTX
The programming philosophy of jrql
msg systems ag
 
PDF
Effective Java with Groovy - How Language Influences Adoption of Good Practices
Naresha K
 
KEY
Clean code and Code Smells
Mario Sangiorgio
 
PPTX
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
.NET Conf UY
 
PDF
Effective Java with Groovy & Kotlin How Languages Influence Adoption of Good ...
Naresha K
 
PDF
Legacy is Good
Uberto Barbini
 
PDF
Refactoring e Code Smells: Seu código está apodrecendo!
Emanuel Canuto
 
PDF
Combatendo code smells em Java
Emmanuel Neri
 
DOCX
Quick Fix Sample
Neeraj Kaushik
 
PDF
JavaFest. Виктор Полищук. Legacy: как победить в гонке
FestGroup
 
PDF
"An introduction to object-oriented programming for those who have never done...
Fwdays
 
PPTX
C:\Fakepath\Combating Software Entropy 2
Hammad Rajjoub
 
PPTX
C:\Fakepath\Combating Software Entropy 2
Hammad Rajjoub
 
PPTX
Solid Software Design Principles
Jon Kruger
 
PPT
Strategy design pattern
aswapnal
 
PPT
Strategy Design Pattern
Ganesh Kolhe
 
Simple design/programming nuggets
Vivek Singh
 
Refactoring legacy code: step-by-step examples
Endava
 
SOLID Principles
Chris Weldon
 
Improving application design with a rich domain model (springone 2007)
Chris Richardson
 
The programming philosophy of jrql
msg systems ag
 
Effective Java with Groovy - How Language Influences Adoption of Good Practices
Naresha K
 
Clean code and Code Smells
Mario Sangiorgio
 
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
.NET Conf UY
 
Effective Java with Groovy & Kotlin How Languages Influence Adoption of Good ...
Naresha K
 
Legacy is Good
Uberto Barbini
 
Refactoring e Code Smells: Seu código está apodrecendo!
Emanuel Canuto
 
Combatendo code smells em Java
Emmanuel Neri
 
Quick Fix Sample
Neeraj Kaushik
 
JavaFest. Виктор Полищук. Legacy: как победить в гонке
FestGroup
 
"An introduction to object-oriented programming for those who have never done...
Fwdays
 
C:\Fakepath\Combating Software Entropy 2
Hammad Rajjoub
 
C:\Fakepath\Combating Software Entropy 2
Hammad Rajjoub
 
Solid Software Design Principles
Jon Kruger
 
Strategy design pattern
aswapnal
 
Strategy Design Pattern
Ganesh Kolhe
 
Ad

More from Victor_Cr (16)

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

Recently uploaded (20)

PDF
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
July Patch Tuesday
Ivanti
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
July Patch Tuesday
Ivanti
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 

Club of anonimous developers "Refactoring: Legacy code"

  • 1. Refactoring: LegacyThe True Hacker's Guide To The Legacy
  • 2. What is...Very old projects, had been written long long ago.
  • 4. Die hard, nobody knows why it is still alive.
  • 5. Market victim, nobody wants this sh%t anymore.
  • 7. Every project in active long term support.What is usually NOT...Badly written projects which are not in production.
  • 10. Every project you don't understand.What do we need?Legacy project.
  • 11. Developers who want refactor it.
  • 12. A customer eager to pay for it.
  • 13. RegEx
  • 16. Open mind – for everything else and many moreMigration #1: from TOM to POM<target name="generate.libs" depends="init" unless="ignore.generate.libdep" description="Generate library dependencies"> <mkdir dir="${build}/svn-checkout"/> <!-- Get here the sources and build the jar --> <ant inheritAll="false"antfile="${build.config.dir}/svnsupport.xml" target="checkout"> <property name="svn.username" value="${svn.username}"/> <property name="svn.password" value="${svn.password}"/> <property name="svn.url" value="${svn.url.eterracore}"/> <property name="svn.target.dir" value="${build}/svn-checkout"/> </ant> <!-- Run the ant into the checkout dir --> <ant inheritAll="false"antfile="${build}/svn-checkout/build.xml" target="jar"> </ant> <copy todir="${libdep.dir}"> <fileset dir="${build}/svn-checkout/build/"> <include name="*.jar"/> </fileset> </copy></target><modules> <module>core</module> <module>demo</module> <module>noncla</module> <module>protocol/bayeux</module> <module>protocol/dwrp</module> <module>protocol/json</module> <module>serverside/guice</module> <module>serverside/hibernate</module> <module>serverside/hibernate2</module> <module>serverside/spring</module> <module>serverside/struts</module> <module>serverside/various</module> <module>serverside/webwork</module> <module>ui/dojo</module> <module>ui/dwr</module> <module>ui/gi</module> <module>ui/jaxer</module> <module>ui/scriptaculous</module> </modules>
  • 17. Migration #2: IoC (DI) FTWpublic 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 drivenActionForward 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 goodLOG.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. Migration #4: Update librariesPros:Newer versions usually better optimized so you will get performance for free.
  • 20. Newer versions have better different integration options.
  • 21. Newer versions can provide richer API sufficient to compete task better/faster/easier.Cons:Newer versions can be incompatible with: JDK, other libraries, old configuration files etc.Migration #5: Code cleanupCollections.sort(list, new Comparator() { public int compare(Object o1, Object o2) {int value; Offer offer1 = (Offer) ((TradeConfirmation) o1).getOffer(); Offer offer2 = (Offer) ((TradeConfirmation) o2).getOffer(); if (offer1.getTradingInterval() < offer2.getTradingInterval()) { value = -1; } else { if (offer1.getTradingInterval() == offer2.getTradingInterval()) { if (offer1.getType() < offer2.getType()) { value = -1; } else { if (offer1.getType() == offer2.getType()) {PartyDef party1 = offer1.getParty().getEffectiveParty(deliveryD);PartyDef party2 = offer2.getParty().getEffectiveParty(deliveryD); if (party1.getName().compareTo(party2.getName()) < 0) { value = -1; } else { if (party1.getName().compareTo(party2.getName()) == 0) { if (offer1.getTradingZone().getEffectiveTradingDef(deliveryD).getIdentification().compareTo(…) < 0) { value = -1; } else { if (offer1.getTradingZone().getEffectiveTradingDef(deliveryD).getIdentification(…)) == 0) { value = 0; } else { value = 1; } } } else { value = 1; } } } else { value = 1; } } } else { value = 1; } } return value; } });
  • 22. Instead of an epilogue...How-to convert “procedural” code to OOP.
  • 23. How-to integrate a DI container.
  • 25. How-to find and eliminate unreadable code.
  • 26. QuestionsProcedure to MethodCopy all “procedural” classes into separate folder.
  • 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. Patiently relocate methods body from old to new classes during whole development process.
  • 32. Ready for DI containerEvery time when we think that IoC (DI) container should either take care of all application classes or not at all – we are wrong.
  • 33. New code must not use the same bad approach as “the legacy” part or it never ends.
  • 34. Even legacy code can sometimes be declared in container context. Singletons for instance.AOP - even more flexibilityIt is a good idea to separate exception handling (at least) from code.
  • 35. If it looks like “aspect”, it is “aspect” with 95% probability, trust me.
  • 36. Annotations with AOP have incredible power.
  • 37. Wisely chosen name conventions, annotations, module structure can make your application working really fast.
  • 38. “Lulz” huntingDevelopers tend to have their own style. If you find something ugly/funny - search it again using a pattern or a regular expression.
  • 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. Sometimes an “ugly” code is not so ugly.