SlideShare a Scribd company logo
OLD CODE DOESN'T STINK
Refactor or Rewrite
Martin Gutenbrunner
LINZ, AUSTRIA - APR 26, 2018
DEVELOPER AND OPS CONFERENCE
ABOUT ME
• Started with Commodore 8-bit (VC-20 and C-64)
• assembled an i386 from second-hand parts as a gaming rig
• Built Null-Modem connections for playing Doom and WarCraft I
• and IPX/SPX networks between MS-DOS 6.22 and WfW 3.11
• Did DevOps before it was a thing
• mainly Java and JavaScript
• saw rotten code and built code that suddely rotted
• Now at Dynatrace
• previous: Tech Lead for Microsoft Azure and Microservices
• now: Software Architect
• About 14 years of experience in the industry
• Find me on Twitter: @MartinGoodwell
Considers himself a lucky guy
ABOUT THE SHOW
• Driven by example
• Example #1: Legacy can mean 15 years
• Example #2: Legacy can mean 5 years
• The basics – aka "Mastering the craft"
• The Magic Sauce, finally (spoiler: there is none)
Online Shop, written in ASP, rendering XHTML
Back then, in development for 15 years
EXAMPLE 1: classic ASP
PROJECT SETUP
• Use-case: eCommerce
• integrated with business backend system
• Native Windows desktop application, connected to database
• Core: classic ASP
• Database: Pervasive SQL
• the actual database from the business backend
• Interfaces to
• MSMQ for sending orders to the business backend
• COM+ for querying prices from the business backend
OLD ARCHITECTURE
ASP UI
XHTML
Business
Backend
System
SQL-DB
MSMQ
(Orders)
COM+
(Prices)
Browser
(XHTML)
WE WANTED TO REWRITE. WHY?
• 15 year old VB-Script codebase
• lack of structure
• not up to today's standards (eg Unit Testing)
• hard to find VB-Script talent
• Too closely bound to the business backend system
• Major updates locked the database and rendered the online shop unusable
CUSTOM BRANCHING
<%
if nCategoryId = 0 and (hostInfo.Path = "clayshop" or hostInfo.Path="bikershop" or hostInfo.Path="steelshop") then
out GetPageHTML(1,"de")
end if
%>
• Individual code branches for most tenants (~30 of them)
• If a tenant canceled his contract, the codebase usually was not
cleaned
RENDERING WHILE ITERATING RECORDSET
<%
set rsProd= oProduct.GetProduct(CLng(nProductId), CLng(nTenantId))
if not rsProd.eof then %>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td><img height="20" width="3" src="../../layout/pic/pix_tr.gif" border="0"></td></tr>
<tr><td class="productheadcolor">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="productheadiconcolor"><img height="20" width="20" src="../../layout/pic/icons/icon_kl_produkttip.gif" border="0"></td>
<td><div class="productheadcolor">&nbsp;<%= getText("product") %>:</div></td>
</tr>
</table>
<% if (sTenantPath <> "that_special_shop") then DrawProducts rsProd, "productreplacement" end if %>
<% end if
rsProd.close
set rsProd= nothing
%>
• No separation between data-access, business logic, and UI
• Made it hard to see what really needs refactoring
OUR PLAN WAS
• 100% re-write in Java
• Create a separate database for eCommerce
• Move all tenants to the new codebase within six months
PLANNED ARCHITECTURE
Business
Backend
SystemSQL
DB
MSMQ
(Orders)
COM+
(Prices)
Importer
Java
Spring MVC
MongoD
B
Browser
(HTML5)
LEARNINGS
• 100% re-write in Java not possible
• no stable Java libraries for MSMQ and COM+ at the time
• Planned timeframe (of course) didn't work
• first tenant went online after 9 months
• but it was using the new UI
• Re-doing the UI turned out to be the hard part
• we still didn't have all tenants converted after 2,5 years
DONE ARCHITECTURE
ASP
Bridge
Business
Backend
SystemSQL
DB
MSMQ
(Orders)
COM+
(Prices)
Importer
Java
MongoD
B
Browser
(HTML5)
ASP
Backend
Browser
(XHTML)
WHAT WENT WELL?
• Introduction of dedicated DB
• Having a separate Importer component
• We built deployment automation with Jenkins
• The ASP-bridge turned out to work really well
WHAT WE SHOULD HAVE DONE
• Identify the UI-part as the real problem
• impossible to see due to no layered code
• Embrace the fact that we have a huge number of customers on the
"old" codebase and design the new system for multiple UI
technologies
• EOL the old codebase
• If customers want new features, migrate them over
INTRODUCING BFF
• BFF
• Backend-for-Frontend
• aka Edge-Service
• source: Sam Newman's Microservice book
• can be used for
• routing
• authentication
• filtering
BETTER ARCHITECTURE
Java
Backend
API-only
Browser
(HTML5)
Browser
(XHTML)
BFF
ASP
BFF
Spring MVC
Android
(JSON)
BFF
Node.js
iOS
(JSON)
MongoDB
ASP-bridge
BENEFITS OF DOING IT RIGHT
• Save months of efforts to port the messy UI code
• Have ASP UI benefit from separate database
• Only have a single touchpoint with the business backend system
• for any client
• XHTML rendered by ASP
• HTML5 rendered by Spring MVC
• potential mobile apps
BUSINESS BACKEND
FIVE YEARS IN THE MAKING
OLD CODE DOESN'T STINK? IT MIGHT SMELL A LOT, THOUGH.
EXAMPLE 2: Java GWT
SETTING THE STAGE
• Problems
• Increasing number of bugs (~ 300k lines of code)
• Steadily decreasing velocity of teams (due to # of bugs)
• DB started to make problems. Regular restarts required (once a quarter)
• Mistakes made
• Bad code structure
• Next to no test coverage
• Solution
• Transition to a manageable scope
• Boyscout rule: leave the campground cleaner than you found it
WHY NOT REWRITE?
• Existing solution in the making for 5 years
• lots of domain knowledge would have to be re-implemented
• very error-prone
• Who would rewrite it?
• Same teams: who would maintain the current version?
• New teams: they would have to learn domain knowledge from scratch
• and new teams don't appear out of nowhere
• Timeline for starting over?
• can you re-implement a five-year-old system in 6/9/12(?) months?
WHY NOT REWRITE?
• We would have built the same thing again
• Even though it seems that a system is broken as a whole, it probably
isn't. Lots of it usually works.
• Our approach: educate the teams
• what went wrong
• how to do better
• And apply their learnings to the existing system instead of creating a
new one
• Plus: bring in new people to the teams
IT MIGHT SMELL, THOUGH.
EDUCATING THE TEAMS
MASTERING THE CRAFT
OLD CODE DOESN'T STINK
HOW CAN THAT EVEN HAPPEN?
• Bounded contexts
• Things built in-house that would have been readily available
• Code that's not testable
• Code that's not clearly/properly structured
• Bugs due to premature optimization
BOUNDED CONTEXTS
Don't mix things that don't belong together
• Do you see what's wrong with the "UserAccount" table?
BOUNDED CONTEXTS
Wrong: sharing DTOs between different domains
Some services use same attributes, some use specific ones
CatalogService
ShoppingCart
Service
OrderService
ProductDto
* id
* name
* description
* userRatings
* imageUrls
* price
* vat
* quantity
BOUNDED CONTEXTS
Right: dedicated DTOs for each domain
but smells like duplication a lot, because of the names
better: each DTO only contains the attributes it needs
CatalogService
ShoppingCart
Service
OrderService
CatalogProductDto
* id
* name
* description
* userRatings
* imageUrls
* price
CartProductDto
* id
* name
* price
* quantity
OrderProductDto
* id
* name
* price
* vat
* quantity
BOUNDED CONTEXTS
Same DTOs, but different names. Much better fit to the domain.
CatalogService
ShoppingCart
Service
OrderService
ProductDto
* id
* name
* description
* userRatings
* imageUrls
* price
CartEntryDto
* id
* name
* price
* quantity
LineItemDto
* id
* name
* price
* vat
* quantity
NOT INVENTED HERE
• Focus on business logic
• Don't build what you don't need to
• Queues
• Connection Pools
• Anything you build needs to be maintained.
• The only thing you'd want to maintain is business logic.
CODE DUPLICATION
CODE DUPLICATION
Wrong: use inheritance for saving number of attributes in classes
abstract class MasterDto {
protected int id;
}
public class AnyDto extends MasterDto {
...
}
public class AnyOtherDto extends MasterDto {
...
}
CODE DUPLICATION
Right: don't mix unrelated objects
public class AnyDto {
private int id;
}
public class AnyOtherDto {
private int id;
}
WHY UNIT TESTS?
TESTABLE CODE
• Methods only deal with atomic operations
• every IF in a method requires a test for every branch
• that's why code inside blocks should go into a separate method
• allows to test that method independently
• any possible input parameters require a test
• any possible return values require a test
• the smaller your classes, the smaller your methods, the easier it is to
maintain test code
• the amount of test code can easily be equal to your "real" code
TESTABLE CODE
• Don't use static classes directly in the code
public class Lala {
public int calcIt(int a, int b) {
return CalculatorUtil.calcIt(a,b);
}
}
TESTABLE CODE
• Instead, make them a Singleton and a member variable
public class Lala {
private CalcUtil calcUtil=CalcUtil.getInstance();
public int calcIt(int a, int b) {
return calcUtil.calcIt(a,b);
}
public void setCalcUtil(CalcUtil calcUtil) {
this.calcUtil = calcUtil;
}
}
AGAIN, NO INTEGRATION TEST DONE
PREMATURE OPTIMIZATION
• "Because we need the performance"
• Can you monitor the language "D"?
• Do everything in Stored Procedures (even simple CRUDs)
• You need to declare that variable outside of the loop to safe the GC from the
load
• Specialize first, generalize later
READ
• Find all this and lots more here:
• Clean Code, by
• Robert C. Martin
READ
• Find all this and lots more here:
• Growing Object-Oriented Software,
guided by Tests, by
• Steve Freeman, Nat Pryce
HOW?
WHAT DOES IT TAKE?
TRANSITIONING TO A MANAGEABLE SCOPE
EXISTING ARCHITECTURE
• Java
• GWT
• SQL-Server
• Interfaces to 3rd parties, like
• Billing systems (SAP, AWS, Monexa, ...)
• Salesforce
• Single-Sign-On
• Deployed on AWS EC2
EXISTING ARCHITECTURE
• 300k lines of code
• 47 projects in Eclipse IDE
• 155 tables in SQL-Server
AWS
Billing
Java
Backend
MSSQLD
B
Customer
facing
GWT UI
GWT-RPC
SAP
Billing
SFDC
Internal
GWT UI
JSON
THE SOLUTION: MICROSERVICES
• Smaller contexts
• easier to grasp
• easier to test
• no dependency hell
• faster to deploy
• less to test
• Smaller databases
• faster queries
• easier for blue/green deployment
• Easier scaling
• just deploy more instances instead of built-in parallelization
IN-FLIGHT ARCHITECTURE
Java
Monolith
MSSQL
Angular
Single
Page App
Java
Microservice
Java
Microservice
Java
Microservice
BFF
Angular
BFF
Android
Android
App
BFF
iOS
iOS
App
AWS
Aurora
AWS
Aurora
AWS
Aurora
BFF
REST
Generic
REST
Client
GWT
BFF/EDGE SPECIFICS
Angular
Single
Page App
BFF
Angular
/rest
BFF
Android
/android
Android
App
BFF
iOS
/ios
iOS
App
BFF
REST
/api
Generic
REST
Client
Authenticated via
Username/Password
Authenticated via
OAUTH
Authenticated via
OAUTH
Authenticated via
OAUTH
JavaScript
served by NGINX
or AWS CloudFront
MICROSERVICES SPECIFICS
• Designed to work that way from ground up
• ie UI can handle single failing micro services
• Think of a platform for deployment
• Automation is key. It always is. But here even more.
SOMETIMES IT JUST CAN'T BE MICROSERVICES
CAN WE USE SOME OF THAT FOR MOBILE OR DESKTOP?
THE PROPER MONOLITH
LAYERS
• One artifact per business domain
• 3-tiered architecture inside of each artifact
• Sharing of interfaces by means of –api artifacts
• No shared database between domains
PROPER MONOLITH
.war file
catalog
.jar
cart
.jar
billing
.jar
order
.jar
Controllers
Physical Database
Catalog
DB
Cart
DB
Billing
DB
Order
DB
TOOLS THAT HELP
• Black Duck
• Sonar
HOW TO DO IT RIGHT FROM NOW ON?
WHAT A REAL REWRITE REALLY MEANS
• June 2006
• Netscape Navigator 6 goes public beta
• last 4.x release released almost 4 years ago (there was no v5)
• https://www.joelonsoftware.com/2000/04/06/things-you-should-
never-do-part-i/
IN A NUTSHELL
• Master the craft of programming
• Avoid the mess
• Bounded Contexts
• Microservices-driven thinking and architecture
LINZ, AUSTRIA - APR 26, 2018
DEVELOPER AND OPS CONFERENCE

More Related Content

What's hot

Pharo Optimising JIT Internals
Pharo Optimising JIT InternalsPharo Optimising JIT Internals
Pharo Optimising JIT Internals
ESUG
 
Aligning Ember.js with Web Standards
Aligning Ember.js with Web StandardsAligning Ember.js with Web Standards
Aligning Ember.js with Web Standards
Matthew Beale
 
Smart Client Development
Smart Client DevelopmentSmart Client Development
Smart Client Development
Tamir Khason
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)
Ran Mizrahi
 
libinjection: a C library for SQLi detection, from Black Hat USA 2012
libinjection: a C library for SQLi detection, from Black Hat USA 2012libinjection: a C library for SQLi detection, from Black Hat USA 2012
libinjection: a C library for SQLi detection, from Black Hat USA 2012
Nick Galbreath
 
libinjection: new technique in detecting SQLi attacks, iSEC Partners Open Forum
libinjection: new technique in detecting SQLi attacks, iSEC Partners Open Forumlibinjection: new technique in detecting SQLi attacks, iSEC Partners Open Forum
libinjection: new technique in detecting SQLi attacks, iSEC Partners Open Forum
Nick Galbreath
 
Cracking JWT tokens: a tale of magic, Node.JS and parallel computing
Cracking JWT tokens: a tale of magic, Node.JS and parallel computingCracking JWT tokens: a tale of magic, Node.JS and parallel computing
Cracking JWT tokens: a tale of magic, Node.JS and parallel computing
Luciano Mammino
 
libinjection and sqli obfuscation, presented at OWASP NYC
libinjection and sqli obfuscation, presented at OWASP NYClibinjection and sqli obfuscation, presented at OWASP NYC
libinjection and sqli obfuscation, presented at OWASP NYC
Nick Galbreath
 
JavaScript Library Overview
JavaScript Library OverviewJavaScript Library Overview
JavaScript Library Overview
jeresig
 
Workin On The Rails Road
Workin On The Rails RoadWorkin On The Rails Road
Workin On The Rails Road
RubyOnRails_dude
 
Hacking Java @JavaLand2016
Hacking Java @JavaLand2016Hacking Java @JavaLand2016
Hacking Java @JavaLand2016
Sean P. Floyd
 
Code lifecycle in the jvm - TopConf Linz
Code lifecycle in the jvm - TopConf LinzCode lifecycle in the jvm - TopConf Linz
Code lifecycle in the jvm - TopConf Linz
Ivan Krylov
 
Web a Quebec - JS Debugging
Web a Quebec - JS DebuggingWeb a Quebec - JS Debugging
Web a Quebec - JS Debugging
Rami Sayar
 
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-publicJavazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
Timothy Perrett
 
SQL-RISC: New Directions in SQLi Prevention - RSA USA 2013
SQL-RISC: New Directions in SQLi Prevention - RSA USA 2013SQL-RISC: New Directions in SQLi Prevention - RSA USA 2013
SQL-RISC: New Directions in SQLi Prevention - RSA USA 2013
Nick Galbreath
 
Hacking Java - Enhancing Java Code at Build or Runtime
Hacking Java - Enhancing Java Code at Build or RuntimeHacking Java - Enhancing Java Code at Build or Runtime
Hacking Java - Enhancing Java Code at Build or Runtime
Sean P. Floyd
 
What to expect from Java 9
What to expect from Java 9What to expect from Java 9
What to expect from Java 9
Ivan Krylov
 
Introduction to mobile reversing
Introduction to mobile reversingIntroduction to mobile reversing
Introduction to mobile reversing
jduart
 
Григорий Шехет "Treasure hunt in the land of Reactive frameworks"
Григорий Шехет "Treasure hunt in the land of Reactive frameworks"Григорий Шехет "Treasure hunt in the land of Reactive frameworks"
Григорий Шехет "Treasure hunt in the land of Reactive frameworks"
Fwdays
 
How to-node-core
How to-node-coreHow to-node-core
How to-node-core
IsaacSchlueter
 

What's hot (20)

Pharo Optimising JIT Internals
Pharo Optimising JIT InternalsPharo Optimising JIT Internals
Pharo Optimising JIT Internals
 
Aligning Ember.js with Web Standards
Aligning Ember.js with Web StandardsAligning Ember.js with Web Standards
Aligning Ember.js with Web Standards
 
Smart Client Development
Smart Client DevelopmentSmart Client Development
Smart Client Development
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)
 
libinjection: a C library for SQLi detection, from Black Hat USA 2012
libinjection: a C library for SQLi detection, from Black Hat USA 2012libinjection: a C library for SQLi detection, from Black Hat USA 2012
libinjection: a C library for SQLi detection, from Black Hat USA 2012
 
libinjection: new technique in detecting SQLi attacks, iSEC Partners Open Forum
libinjection: new technique in detecting SQLi attacks, iSEC Partners Open Forumlibinjection: new technique in detecting SQLi attacks, iSEC Partners Open Forum
libinjection: new technique in detecting SQLi attacks, iSEC Partners Open Forum
 
Cracking JWT tokens: a tale of magic, Node.JS and parallel computing
Cracking JWT tokens: a tale of magic, Node.JS and parallel computingCracking JWT tokens: a tale of magic, Node.JS and parallel computing
Cracking JWT tokens: a tale of magic, Node.JS and parallel computing
 
libinjection and sqli obfuscation, presented at OWASP NYC
libinjection and sqli obfuscation, presented at OWASP NYClibinjection and sqli obfuscation, presented at OWASP NYC
libinjection and sqli obfuscation, presented at OWASP NYC
 
JavaScript Library Overview
JavaScript Library OverviewJavaScript Library Overview
JavaScript Library Overview
 
Workin On The Rails Road
Workin On The Rails RoadWorkin On The Rails Road
Workin On The Rails Road
 
Hacking Java @JavaLand2016
Hacking Java @JavaLand2016Hacking Java @JavaLand2016
Hacking Java @JavaLand2016
 
Code lifecycle in the jvm - TopConf Linz
Code lifecycle in the jvm - TopConf LinzCode lifecycle in the jvm - TopConf Linz
Code lifecycle in the jvm - TopConf Linz
 
Web a Quebec - JS Debugging
Web a Quebec - JS DebuggingWeb a Quebec - JS Debugging
Web a Quebec - JS Debugging
 
Javazone 2010-lift-framework-public
Javazone 2010-lift-framework-publicJavazone 2010-lift-framework-public
Javazone 2010-lift-framework-public
 
SQL-RISC: New Directions in SQLi Prevention - RSA USA 2013
SQL-RISC: New Directions in SQLi Prevention - RSA USA 2013SQL-RISC: New Directions in SQLi Prevention - RSA USA 2013
SQL-RISC: New Directions in SQLi Prevention - RSA USA 2013
 
Hacking Java - Enhancing Java Code at Build or Runtime
Hacking Java - Enhancing Java Code at Build or RuntimeHacking Java - Enhancing Java Code at Build or Runtime
Hacking Java - Enhancing Java Code at Build or Runtime
 
What to expect from Java 9
What to expect from Java 9What to expect from Java 9
What to expect from Java 9
 
Introduction to mobile reversing
Introduction to mobile reversingIntroduction to mobile reversing
Introduction to mobile reversing
 
Григорий Шехет "Treasure hunt in the land of Reactive frameworks"
Григорий Шехет "Treasure hunt in the land of Reactive frameworks"Григорий Шехет "Treasure hunt in the land of Reactive frameworks"
Григорий Шехет "Treasure hunt in the land of Reactive frameworks"
 
How to-node-core
How to-node-coreHow to-node-core
How to-node-core
 

Similar to Old code doesn't stink

Old code doesn't stink - Detroit
Old code doesn't stink - DetroitOld code doesn't stink - Detroit
Old code doesn't stink - Detroit
Martin Gutenbrunner
 
Basic Application Performance Optimization Techniques (Backend)
Basic Application Performance Optimization Techniques (Backend)Basic Application Performance Optimization Techniques (Backend)
Basic Application Performance Optimization Techniques (Backend)
Klas Berlič Fras
 
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
Speedment, Inc.
 
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
Malin Weiss
 
Auto cad 2006_api_overview
Auto cad 2006_api_overviewAuto cad 2006_api_overview
Auto cad 2006_api_overview
scdhruv5
 
Silicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your databaseSilicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your database
Speedment, Inc.
 
How to generate customized java 8 code from your database
How to generate customized java 8 code from your databaseHow to generate customized java 8 code from your database
How to generate customized java 8 code from your database
Speedment, Inc.
 
Improving the Quality of Existing Software
Improving the Quality of Existing SoftwareImproving the Quality of Existing Software
Improving the Quality of Existing Software
Steven Smith
 
Node azure
Node azureNode azure
Node azure
Emanuele DelBono
 
Improving the Quality of Existing Software - DevIntersection April 2016
Improving the Quality of Existing Software - DevIntersection April 2016Improving the Quality of Existing Software - DevIntersection April 2016
Improving the Quality of Existing Software - DevIntersection April 2016
Steven Smith
 
Sista: Improving Cog’s JIT performance
Sista: Improving Cog’s JIT performanceSista: Improving Cog’s JIT performance
Sista: Improving Cog’s JIT performance
ESUG
 
Novedades de MongoDB 3.6
Novedades de MongoDB 3.6Novedades de MongoDB 3.6
Novedades de MongoDB 3.6
MongoDB
 
Web Development using Ruby on Rails
Web Development using Ruby on RailsWeb Development using Ruby on Rails
Web Development using Ruby on Rails
Avi Kedar
 
[DBA]_HiramFleitas_SQL_PASS_Summit_2017_Summary
[DBA]_HiramFleitas_SQL_PASS_Summit_2017_Summary[DBA]_HiramFleitas_SQL_PASS_Summit_2017_Summary
[DBA]_HiramFleitas_SQL_PASS_Summit_2017_Summary
Hiram Fleitas León
 
Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...
Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...
Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...
Anupam Ranku
 
Improving the Quality of Existing Software
Improving the Quality of Existing SoftwareImproving the Quality of Existing Software
Improving the Quality of Existing Software
Steven Smith
 
Machine Learning with ML.NET and Azure - Andy Cross
Machine Learning with ML.NET and Azure - Andy CrossMachine Learning with ML.NET and Azure - Andy Cross
Machine Learning with ML.NET and Azure - Andy Cross
Andrew Flatters
 
CBDW2014 - Behavior Driven Development with TestBox
CBDW2014 - Behavior Driven Development with TestBoxCBDW2014 - Behavior Driven Development with TestBox
CBDW2014 - Behavior Driven Development with TestBox
Ortus Solutions, Corp
 
Why real integration developers ride Camels
Why real integration developers ride CamelsWhy real integration developers ride Camels
Why real integration developers ride Camels
Christian Posta
 
Tech trends 2018 2019
Tech trends 2018 2019Tech trends 2018 2019
Tech trends 2018 2019
Johan Norm
 

Similar to Old code doesn't stink (20)

Old code doesn't stink - Detroit
Old code doesn't stink - DetroitOld code doesn't stink - Detroit
Old code doesn't stink - Detroit
 
Basic Application Performance Optimization Techniques (Backend)
Basic Application Performance Optimization Techniques (Backend)Basic Application Performance Optimization Techniques (Backend)
Basic Application Performance Optimization Techniques (Backend)
 
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
 
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
 
Auto cad 2006_api_overview
Auto cad 2006_api_overviewAuto cad 2006_api_overview
Auto cad 2006_api_overview
 
Silicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your databaseSilicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your database
 
How to generate customized java 8 code from your database
How to generate customized java 8 code from your databaseHow to generate customized java 8 code from your database
How to generate customized java 8 code from your database
 
Improving the Quality of Existing Software
Improving the Quality of Existing SoftwareImproving the Quality of Existing Software
Improving the Quality of Existing Software
 
Node azure
Node azureNode azure
Node azure
 
Improving the Quality of Existing Software - DevIntersection April 2016
Improving the Quality of Existing Software - DevIntersection April 2016Improving the Quality of Existing Software - DevIntersection April 2016
Improving the Quality of Existing Software - DevIntersection April 2016
 
Sista: Improving Cog’s JIT performance
Sista: Improving Cog’s JIT performanceSista: Improving Cog’s JIT performance
Sista: Improving Cog’s JIT performance
 
Novedades de MongoDB 3.6
Novedades de MongoDB 3.6Novedades de MongoDB 3.6
Novedades de MongoDB 3.6
 
Web Development using Ruby on Rails
Web Development using Ruby on RailsWeb Development using Ruby on Rails
Web Development using Ruby on Rails
 
[DBA]_HiramFleitas_SQL_PASS_Summit_2017_Summary
[DBA]_HiramFleitas_SQL_PASS_Summit_2017_Summary[DBA]_HiramFleitas_SQL_PASS_Summit_2017_Summary
[DBA]_HiramFleitas_SQL_PASS_Summit_2017_Summary
 
Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...
Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...
Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...
 
Improving the Quality of Existing Software
Improving the Quality of Existing SoftwareImproving the Quality of Existing Software
Improving the Quality of Existing Software
 
Machine Learning with ML.NET and Azure - Andy Cross
Machine Learning with ML.NET and Azure - Andy CrossMachine Learning with ML.NET and Azure - Andy Cross
Machine Learning with ML.NET and Azure - Andy Cross
 
CBDW2014 - Behavior Driven Development with TestBox
CBDW2014 - Behavior Driven Development with TestBoxCBDW2014 - Behavior Driven Development with TestBox
CBDW2014 - Behavior Driven Development with TestBox
 
Why real integration developers ride Camels
Why real integration developers ride CamelsWhy real integration developers ride Camels
Why real integration developers ride Camels
 
Tech trends 2018 2019
Tech trends 2018 2019Tech trends 2018 2019
Tech trends 2018 2019
 

More from Martin Gutenbrunner

Smart Home - 10 Jahre danach
Smart Home - 10 Jahre danachSmart Home - 10 Jahre danach
Smart Home - 10 Jahre danach
Martin Gutenbrunner
 
DevOne - How to not fail with Azure
DevOne - How to not fail with AzureDevOne - How to not fail with Azure
DevOne - How to not fail with Azure
Martin Gutenbrunner
 
APIs in production - we built it, can we fix it?
APIs in production - we built it, can we fix it?APIs in production - we built it, can we fix it?
APIs in production - we built it, can we fix it?
Martin Gutenbrunner
 
Pushing the hassle from production to developers. Easily
Pushing the hassle from production to developers. EasilyPushing the hassle from production to developers. Easily
Pushing the hassle from production to developers. Easily
Martin Gutenbrunner
 
Monitoring 101 - Leveraging on the power of JMX
Monitoring 101 - Leveraging on the power of JMXMonitoring 101 - Leveraging on the power of JMX
Monitoring 101 - Leveraging on the power of JMX
Martin Gutenbrunner
 
Performance monitoring and call tracing in microservice environments
Performance monitoring and call tracing in microservice environmentsPerformance monitoring and call tracing in microservice environments
Performance monitoring and call tracing in microservice environments
Martin Gutenbrunner
 

More from Martin Gutenbrunner (6)

Smart Home - 10 Jahre danach
Smart Home - 10 Jahre danachSmart Home - 10 Jahre danach
Smart Home - 10 Jahre danach
 
DevOne - How to not fail with Azure
DevOne - How to not fail with AzureDevOne - How to not fail with Azure
DevOne - How to not fail with Azure
 
APIs in production - we built it, can we fix it?
APIs in production - we built it, can we fix it?APIs in production - we built it, can we fix it?
APIs in production - we built it, can we fix it?
 
Pushing the hassle from production to developers. Easily
Pushing the hassle from production to developers. EasilyPushing the hassle from production to developers. Easily
Pushing the hassle from production to developers. Easily
 
Monitoring 101 - Leveraging on the power of JMX
Monitoring 101 - Leveraging on the power of JMXMonitoring 101 - Leveraging on the power of JMX
Monitoring 101 - Leveraging on the power of JMX
 
Performance monitoring and call tracing in microservice environments
Performance monitoring and call tracing in microservice environmentsPerformance monitoring and call tracing in microservice environments
Performance monitoring and call tracing in microservice environments
 

Recently uploaded

The Rise of AI in Cybersecurity How Machine Learning Will Shape Threat Detect...
The Rise of AI in Cybersecurity How Machine Learning Will Shape Threat Detect...The Rise of AI in Cybersecurity How Machine Learning Will Shape Threat Detect...
The Rise of AI in Cybersecurity How Machine Learning Will Shape Threat Detect...
digitalxplive
 
Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)
Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)
Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)
Muhammad Ali
 
Three New Criminal Laws in India 1 July 2024
Three New Criminal Laws in India 1 July 2024Three New Criminal Laws in India 1 July 2024
Three New Criminal Laws in India 1 July 2024
aakash malhotra
 
Dublin_mulesoft_meetup_Mulesoft_Salesforce_Integration (1).pptx
Dublin_mulesoft_meetup_Mulesoft_Salesforce_Integration (1).pptxDublin_mulesoft_meetup_Mulesoft_Salesforce_Integration (1).pptx
Dublin_mulesoft_meetup_Mulesoft_Salesforce_Integration (1).pptx
Kunal Gupta
 
Tirana Tech Meetup - Agentic RAG with Milvus, Llama3 and Ollama
Tirana Tech Meetup - Agentic RAG with Milvus, Llama3 and OllamaTirana Tech Meetup - Agentic RAG with Milvus, Llama3 and Ollama
Tirana Tech Meetup - Agentic RAG with Milvus, Llama3 and Ollama
Zilliz
 
Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery
Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery
Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery
sunilverma7884
 
Using LLM Agents with Llama 3, LangGraph and Milvus
Using LLM Agents with Llama 3, LangGraph and MilvusUsing LLM Agents with Llama 3, LangGraph and Milvus
Using LLM Agents with Llama 3, LangGraph and Milvus
Zilliz
 
Best Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdfBest Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdf
Tatiana Al-Chueyr
 
Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...
Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...
Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...
maigasapphire
 
“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...
“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...
“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...
Edge AI and Vision Alliance
 
Google I/O Extended Harare Merged Slides
Google I/O Extended Harare Merged SlidesGoogle I/O Extended Harare Merged Slides
Google I/O Extended Harare Merged Slides
Google Developer Group - Harare
 
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptxRPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
SynapseIndia
 
How to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptxHow to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptx
Adam Dunkels
 
The Role of IoT in Australian Mobile App Development - PDF Guide
The Role of IoT in Australian Mobile App Development - PDF GuideThe Role of IoT in Australian Mobile App Development - PDF Guide
The Role of IoT in Australian Mobile App Development - PDF Guide
Shiv Technolabs
 
(CISOPlatform Summit & SACON 2024) Keynote _ Power Digital Identities With AI...
(CISOPlatform Summit & SACON 2024) Keynote _ Power Digital Identities With AI...(CISOPlatform Summit & SACON 2024) Keynote _ Power Digital Identities With AI...
(CISOPlatform Summit & SACON 2024) Keynote _ Power Digital Identities With AI...
Priyanka Aash
 
WhatsApp Spy Online Trackers and Monitoring Apps
WhatsApp Spy Online Trackers and Monitoring AppsWhatsApp Spy Online Trackers and Monitoring Apps
WhatsApp Spy Online Trackers and Monitoring Apps
HackersList
 
Acumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdf
Acumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdfAcumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdf
Acumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdf
BrainSell Technologies
 
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdfBT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
Neo4j
 
"Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes...
"Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes..."Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes...
"Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes...
Anant Gupta
 
Evolution of iPaaS - simplify IT workloads to provide a unified view of data...
Evolution of iPaaS - simplify IT workloads to provide a unified view of  data...Evolution of iPaaS - simplify IT workloads to provide a unified view of  data...
Evolution of iPaaS - simplify IT workloads to provide a unified view of data...
Torry Harris
 

Recently uploaded (20)

The Rise of AI in Cybersecurity How Machine Learning Will Shape Threat Detect...
The Rise of AI in Cybersecurity How Machine Learning Will Shape Threat Detect...The Rise of AI in Cybersecurity How Machine Learning Will Shape Threat Detect...
The Rise of AI in Cybersecurity How Machine Learning Will Shape Threat Detect...
 
Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)
Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)
Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)
 
Three New Criminal Laws in India 1 July 2024
Three New Criminal Laws in India 1 July 2024Three New Criminal Laws in India 1 July 2024
Three New Criminal Laws in India 1 July 2024
 
Dublin_mulesoft_meetup_Mulesoft_Salesforce_Integration (1).pptx
Dublin_mulesoft_meetup_Mulesoft_Salesforce_Integration (1).pptxDublin_mulesoft_meetup_Mulesoft_Salesforce_Integration (1).pptx
Dublin_mulesoft_meetup_Mulesoft_Salesforce_Integration (1).pptx
 
Tirana Tech Meetup - Agentic RAG with Milvus, Llama3 and Ollama
Tirana Tech Meetup - Agentic RAG with Milvus, Llama3 and OllamaTirana Tech Meetup - Agentic RAG with Milvus, Llama3 and Ollama
Tirana Tech Meetup - Agentic RAG with Milvus, Llama3 and Ollama
 
Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery
Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery
Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery
 
Using LLM Agents with Llama 3, LangGraph and Milvus
Using LLM Agents with Llama 3, LangGraph and MilvusUsing LLM Agents with Llama 3, LangGraph and Milvus
Using LLM Agents with Llama 3, LangGraph and Milvus
 
Best Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdfBest Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdf
 
Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...
Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...
Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...
 
“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...
“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...
“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...
 
Google I/O Extended Harare Merged Slides
Google I/O Extended Harare Merged SlidesGoogle I/O Extended Harare Merged Slides
Google I/O Extended Harare Merged Slides
 
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptxRPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
 
How to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptxHow to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptx
 
The Role of IoT in Australian Mobile App Development - PDF Guide
The Role of IoT in Australian Mobile App Development - PDF GuideThe Role of IoT in Australian Mobile App Development - PDF Guide
The Role of IoT in Australian Mobile App Development - PDF Guide
 
(CISOPlatform Summit & SACON 2024) Keynote _ Power Digital Identities With AI...
(CISOPlatform Summit & SACON 2024) Keynote _ Power Digital Identities With AI...(CISOPlatform Summit & SACON 2024) Keynote _ Power Digital Identities With AI...
(CISOPlatform Summit & SACON 2024) Keynote _ Power Digital Identities With AI...
 
WhatsApp Spy Online Trackers and Monitoring Apps
WhatsApp Spy Online Trackers and Monitoring AppsWhatsApp Spy Online Trackers and Monitoring Apps
WhatsApp Spy Online Trackers and Monitoring Apps
 
Acumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdf
Acumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdfAcumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdf
Acumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdf
 
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdfBT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
 
"Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes...
"Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes..."Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes...
"Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes...
 
Evolution of iPaaS - simplify IT workloads to provide a unified view of data...
Evolution of iPaaS - simplify IT workloads to provide a unified view of  data...Evolution of iPaaS - simplify IT workloads to provide a unified view of  data...
Evolution of iPaaS - simplify IT workloads to provide a unified view of data...
 

Old code doesn't stink

  • 1. OLD CODE DOESN'T STINK Refactor or Rewrite Martin Gutenbrunner LINZ, AUSTRIA - APR 26, 2018 DEVELOPER AND OPS CONFERENCE
  • 2. ABOUT ME • Started with Commodore 8-bit (VC-20 and C-64) • assembled an i386 from second-hand parts as a gaming rig • Built Null-Modem connections for playing Doom and WarCraft I • and IPX/SPX networks between MS-DOS 6.22 and WfW 3.11 • Did DevOps before it was a thing • mainly Java and JavaScript • saw rotten code and built code that suddely rotted • Now at Dynatrace • previous: Tech Lead for Microsoft Azure and Microservices • now: Software Architect • About 14 years of experience in the industry • Find me on Twitter: @MartinGoodwell Considers himself a lucky guy
  • 3. ABOUT THE SHOW • Driven by example • Example #1: Legacy can mean 15 years • Example #2: Legacy can mean 5 years • The basics – aka "Mastering the craft" • The Magic Sauce, finally (spoiler: there is none)
  • 4. Online Shop, written in ASP, rendering XHTML Back then, in development for 15 years EXAMPLE 1: classic ASP
  • 5. PROJECT SETUP • Use-case: eCommerce • integrated with business backend system • Native Windows desktop application, connected to database • Core: classic ASP • Database: Pervasive SQL • the actual database from the business backend • Interfaces to • MSMQ for sending orders to the business backend • COM+ for querying prices from the business backend
  • 7. WE WANTED TO REWRITE. WHY? • 15 year old VB-Script codebase • lack of structure • not up to today's standards (eg Unit Testing) • hard to find VB-Script talent • Too closely bound to the business backend system • Major updates locked the database and rendered the online shop unusable
  • 8. CUSTOM BRANCHING <% if nCategoryId = 0 and (hostInfo.Path = "clayshop" or hostInfo.Path="bikershop" or hostInfo.Path="steelshop") then out GetPageHTML(1,"de") end if %> • Individual code branches for most tenants (~30 of them) • If a tenant canceled his contract, the codebase usually was not cleaned
  • 9. RENDERING WHILE ITERATING RECORDSET <% set rsProd= oProduct.GetProduct(CLng(nProductId), CLng(nTenantId)) if not rsProd.eof then %> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr><td><img height="20" width="3" src="../../layout/pic/pix_tr.gif" border="0"></td></tr> <tr><td class="productheadcolor"> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td class="productheadiconcolor"><img height="20" width="20" src="../../layout/pic/icons/icon_kl_produkttip.gif" border="0"></td> <td><div class="productheadcolor">&nbsp;<%= getText("product") %>:</div></td> </tr> </table> <% if (sTenantPath <> "that_special_shop") then DrawProducts rsProd, "productreplacement" end if %> <% end if rsProd.close set rsProd= nothing %> • No separation between data-access, business logic, and UI • Made it hard to see what really needs refactoring
  • 10. OUR PLAN WAS • 100% re-write in Java • Create a separate database for eCommerce • Move all tenants to the new codebase within six months
  • 12. LEARNINGS • 100% re-write in Java not possible • no stable Java libraries for MSMQ and COM+ at the time • Planned timeframe (of course) didn't work • first tenant went online after 9 months • but it was using the new UI • Re-doing the UI turned out to be the hard part • we still didn't have all tenants converted after 2,5 years
  • 14. WHAT WENT WELL? • Introduction of dedicated DB • Having a separate Importer component • We built deployment automation with Jenkins • The ASP-bridge turned out to work really well
  • 15. WHAT WE SHOULD HAVE DONE • Identify the UI-part as the real problem • impossible to see due to no layered code • Embrace the fact that we have a huge number of customers on the "old" codebase and design the new system for multiple UI technologies • EOL the old codebase • If customers want new features, migrate them over
  • 16. INTRODUCING BFF • BFF • Backend-for-Frontend • aka Edge-Service • source: Sam Newman's Microservice book • can be used for • routing • authentication • filtering
  • 18. BENEFITS OF DOING IT RIGHT • Save months of efforts to port the messy UI code • Have ASP UI benefit from separate database • Only have a single touchpoint with the business backend system • for any client • XHTML rendered by ASP • HTML5 rendered by Spring MVC • potential mobile apps
  • 19. BUSINESS BACKEND FIVE YEARS IN THE MAKING OLD CODE DOESN'T STINK? IT MIGHT SMELL A LOT, THOUGH. EXAMPLE 2: Java GWT
  • 20. SETTING THE STAGE • Problems • Increasing number of bugs (~ 300k lines of code) • Steadily decreasing velocity of teams (due to # of bugs) • DB started to make problems. Regular restarts required (once a quarter) • Mistakes made • Bad code structure • Next to no test coverage • Solution • Transition to a manageable scope • Boyscout rule: leave the campground cleaner than you found it
  • 21. WHY NOT REWRITE? • Existing solution in the making for 5 years • lots of domain knowledge would have to be re-implemented • very error-prone • Who would rewrite it? • Same teams: who would maintain the current version? • New teams: they would have to learn domain knowledge from scratch • and new teams don't appear out of nowhere • Timeline for starting over? • can you re-implement a five-year-old system in 6/9/12(?) months?
  • 22. WHY NOT REWRITE? • We would have built the same thing again • Even though it seems that a system is broken as a whole, it probably isn't. Lots of it usually works. • Our approach: educate the teams • what went wrong • how to do better • And apply their learnings to the existing system instead of creating a new one • Plus: bring in new people to the teams
  • 23. IT MIGHT SMELL, THOUGH. EDUCATING THE TEAMS MASTERING THE CRAFT OLD CODE DOESN'T STINK
  • 24. HOW CAN THAT EVEN HAPPEN? • Bounded contexts • Things built in-house that would have been readily available • Code that's not testable • Code that's not clearly/properly structured • Bugs due to premature optimization
  • 25. BOUNDED CONTEXTS Don't mix things that don't belong together • Do you see what's wrong with the "UserAccount" table?
  • 26. BOUNDED CONTEXTS Wrong: sharing DTOs between different domains Some services use same attributes, some use specific ones CatalogService ShoppingCart Service OrderService ProductDto * id * name * description * userRatings * imageUrls * price * vat * quantity
  • 27. BOUNDED CONTEXTS Right: dedicated DTOs for each domain but smells like duplication a lot, because of the names better: each DTO only contains the attributes it needs CatalogService ShoppingCart Service OrderService CatalogProductDto * id * name * description * userRatings * imageUrls * price CartProductDto * id * name * price * quantity OrderProductDto * id * name * price * vat * quantity
  • 28. BOUNDED CONTEXTS Same DTOs, but different names. Much better fit to the domain. CatalogService ShoppingCart Service OrderService ProductDto * id * name * description * userRatings * imageUrls * price CartEntryDto * id * name * price * quantity LineItemDto * id * name * price * vat * quantity
  • 29. NOT INVENTED HERE • Focus on business logic • Don't build what you don't need to • Queues • Connection Pools • Anything you build needs to be maintained. • The only thing you'd want to maintain is business logic.
  • 31. CODE DUPLICATION Wrong: use inheritance for saving number of attributes in classes abstract class MasterDto { protected int id; } public class AnyDto extends MasterDto { ... } public class AnyOtherDto extends MasterDto { ... }
  • 32. CODE DUPLICATION Right: don't mix unrelated objects public class AnyDto { private int id; } public class AnyOtherDto { private int id; }
  • 34. TESTABLE CODE • Methods only deal with atomic operations • every IF in a method requires a test for every branch • that's why code inside blocks should go into a separate method • allows to test that method independently • any possible input parameters require a test • any possible return values require a test • the smaller your classes, the smaller your methods, the easier it is to maintain test code • the amount of test code can easily be equal to your "real" code
  • 35. TESTABLE CODE • Don't use static classes directly in the code public class Lala { public int calcIt(int a, int b) { return CalculatorUtil.calcIt(a,b); } }
  • 36. TESTABLE CODE • Instead, make them a Singleton and a member variable public class Lala { private CalcUtil calcUtil=CalcUtil.getInstance(); public int calcIt(int a, int b) { return calcUtil.calcIt(a,b); } public void setCalcUtil(CalcUtil calcUtil) { this.calcUtil = calcUtil; } }
  • 38. PREMATURE OPTIMIZATION • "Because we need the performance" • Can you monitor the language "D"? • Do everything in Stored Procedures (even simple CRUDs) • You need to declare that variable outside of the loop to safe the GC from the load • Specialize first, generalize later
  • 39. READ • Find all this and lots more here: • Clean Code, by • Robert C. Martin
  • 40. READ • Find all this and lots more here: • Growing Object-Oriented Software, guided by Tests, by • Steve Freeman, Nat Pryce
  • 41. HOW? WHAT DOES IT TAKE? TRANSITIONING TO A MANAGEABLE SCOPE
  • 42. EXISTING ARCHITECTURE • Java • GWT • SQL-Server • Interfaces to 3rd parties, like • Billing systems (SAP, AWS, Monexa, ...) • Salesforce • Single-Sign-On • Deployed on AWS EC2
  • 43. EXISTING ARCHITECTURE • 300k lines of code • 47 projects in Eclipse IDE • 155 tables in SQL-Server AWS Billing Java Backend MSSQLD B Customer facing GWT UI GWT-RPC SAP Billing SFDC Internal GWT UI JSON
  • 44. THE SOLUTION: MICROSERVICES • Smaller contexts • easier to grasp • easier to test • no dependency hell • faster to deploy • less to test • Smaller databases • faster queries • easier for blue/green deployment • Easier scaling • just deploy more instances instead of built-in parallelization
  • 46. BFF/EDGE SPECIFICS Angular Single Page App BFF Angular /rest BFF Android /android Android App BFF iOS /ios iOS App BFF REST /api Generic REST Client Authenticated via Username/Password Authenticated via OAUTH Authenticated via OAUTH Authenticated via OAUTH JavaScript served by NGINX or AWS CloudFront
  • 47. MICROSERVICES SPECIFICS • Designed to work that way from ground up • ie UI can handle single failing micro services • Think of a platform for deployment • Automation is key. It always is. But here even more.
  • 48. SOMETIMES IT JUST CAN'T BE MICROSERVICES CAN WE USE SOME OF THAT FOR MOBILE OR DESKTOP? THE PROPER MONOLITH
  • 49. LAYERS • One artifact per business domain • 3-tiered architecture inside of each artifact • Sharing of interfaces by means of –api artifacts • No shared database between domains
  • 51. TOOLS THAT HELP • Black Duck • Sonar
  • 52. HOW TO DO IT RIGHT FROM NOW ON?
  • 53. WHAT A REAL REWRITE REALLY MEANS • June 2006 • Netscape Navigator 6 goes public beta • last 4.x release released almost 4 years ago (there was no v5) • https://www.joelonsoftware.com/2000/04/06/things-you-should- never-do-part-i/
  • 54. IN A NUTSHELL • Master the craft of programming • Avoid the mess • Bounded Contexts • Microservices-driven thinking and architecture
  • 55. LINZ, AUSTRIA - APR 26, 2018 DEVELOPER AND OPS CONFERENCE