I’ve just inherited 1,000,000 lines of code…
now what?
Michael Rozlog
Product Manager, RAD Studio, Delphi for PHP, and 3rd Rail1

Who is Mike?
• You just said that
– Product Manager – RAD Studio, Delphi for PHP, 3rd Rail• Responsibilities– Helping to build the developer tools that help developers develop worldclass applications• Current research areas– Software Archeology– Situational Applications– Pushing the RIEA approach – MS’s Software+Services• Prior Position at Borland– Chief Technical Architect – Borland– Creator of Mastering JBuilder – Wiley Books

michael.rozlog@codegear.com

Agenda• What is software Archeology?
• The process: Software Archeology?
• Demonstration• Q&A3Current state of IT around the world• Down economy means less new projects, but more
maintenance and updating existing software• However…
• The need for new or modernizing applications is notdecreasing or going away
• U.S. had the lowest C/S graduation in 2007
– Qualified individuals are not filling the market• Outsourcing is not always a solution on the table?
– Not allowed or applicable– Bigger issues around this area, latest data shows 50% for non-governmentorganizations• Knowledge transfer gap

Questions to you…
• How many have inherited code in the last 6months that you are now responsible for?
• How many have either sent off or received
outsourced projects in the last year?
• How many find it hard to retain and keepskilled employees?
• How many have new members on there
team in the last 3 months?

process
WhatTheis Software
Archeology?

What is Software Archeology?
• A process for approaching unknown softwarethat we have become responsible for…
• An approach to unraveling the complexities ofan existing application• The analysis of past applications to learn andunderstand why it was done that waySoftware Archeology

procedure
TFormMain.DoPageShow(Sender:TObject);if (host.charAt(0)== '.')
var
void return
AddControls(TWinControl* AWinControl, TStrings* Strings)
TWinControl;{Ctrl:
non_proxy_dom_list.removeElement(host);
for(int i=0; i < AWinControl->ControlCount; i++)begin{
PackageInstaller.BeginUpdate;//ifcheckfor host name(dynamic_cast<TWinControl*>(AWinControl->Controls[i]))tryAddControls(dynamic_cast<TWinControl*>(AWinControlfor(intidx=0;
idx<host.length();idx++) {Ctrl := CreatePage(Senderas TJvWizardInteriorPage,>Controls[i]),Strings);
if(!Character.isDigit(host.charAt(idx))&&
PackageInstaller.Page);elsehost.charAt(idx)!='.'&&host.charAt(idx)!= '/')
while(Ctrl<>nil)and(notCtrl.Enabled)do
AddCtrl(AWinControl->Controls[i], Strings);
returnCtrl:= FindNextControl(Ctrl,AddCtrl(AWinControl,Strings); True, False, False);:= Ctrl;}ActiveControl(non_proxy_host_list.remove(host)!= null);}} DoUpdateNavigation(Sender);//finallymust be an IP-address
PackageInstaller.EndUpdate;end;

Software Archeology

Visualization

DesignViolation

if (host.charAt(0) == '.')
returnnon_proxy_dom_list.removeElement(host);// check for host namefor (int idx=0; idx<host.length(); idx++) {if (!Character.isDigit(host.charAt(idx)) &&host.charAt(idx) != '.' && host.charAt(idx) != '/')
return(non_proxy_host_list.remove(host) != null);}// must be an IP-address

DocumentationPerformance
Review

Style
Violations

Business
Logic Review

Software Archeology

if (host.charAt(0) == '.')
returnnon_proxy_dom_list.removeElement(host);// check for host namefor (int idx=0; idx<host.length(); idx++) {if (!Character.isDigit(host.charAt(idx)) &&host.charAt(idx) != '.' && host.charAt(idx) != '/')
return(non_proxy_host_list.remove(host) != null);}// must be an IP-addressSoftware Archeology

Visualization

DesignViolation

if (host.charAt(0) == '.')
returnnon_proxy_dom_list.removeElement(host);// check for host namefor (int idx=0; idx<host.length(); idx++) {if (!Character.isDigit(host.charAt(idx)) &&host.charAt(idx) != '.' && host.charAt(idx) != '/')
return(non_proxy_host_list.remove(host) != null);}// must be an IP-address

Documentation

Performance
Review

Style
Violations

Business
Logic Review

Why is Software Archeology important?

• Always asked to rebuild the wheel– How many times have you been asked torecreate this current implementation, butbetter?

• Inheritance of code
• Outsourcing• Graying of IT

Why is Software Archeology important?

• Always asked to rebuild the wheel• Inheritance of code
– How many times have you picked up
someone else's code or project… to beenhanced?

• Outsourcing• Graying of IT

Why is Software Archeology important?
• Always asked to rebuild the wheel• Inheritance of code
• Outsourcing– Projects get outsourced, rural sourced, insourced, local sourced, and every other kind ofsourced…
– Do you understand the systems that werecreated?
– Do the outsourcers understand the system theyare inheriting?

• Graying of IT

Why is Software Archeology important?

• Always asked to rebuild the wheel• Inheritance of code
• Outsourcing• Graying of IT– By 2010… almost 37% of the software industry
will consist of persons older then 50!
– 60% of the federal workforce will be eligible toretire over the next 10 years• By 2010… 18.5 percent of the government workforce– about 290,000 employees – will retire– Do you understand the systems they havecreated?

What can be learned?
• High-level architectural understanding• Weak-points in existing software– Maintenance nightmares– Performance bottlenecks• Standards compliance or lack there of…
• The overall health and value of theapplication• Architectural approaches or how not tosolve a problem• Finding and Harvesting of Algorithms andpatterns

What tools are needed?
• Need to be able to get a picture• Need to be able to do static analysis• Need to be able to do Dynamic analysis• Need to be able to test the system• Can it be done by hand?
– Yes… but very time consuming… code reviews,
system tests, and primitive system performancemodels• Is there a better way?
– Use a software toolWhat is the cost of code reviews• Very controversial subject• But for me tools can enhance the approach• Task– Review by hand a small example set of code
• 5 classes, 139 lines of code, 4 “experts” in 15 minutes• Average audit violations detected:
21
time: 0.25 hr• Comparison– The same set of code analyzed by a machine:• Audit violations detected:

150

time: 2 sec– Humans @ 84/hr – U.S.

• Real “sample” Project– 187,600 violations in 100 minutes on a project with 1233 classes and199,146 lines of code
– 32,443 violations using the default set– Actual customer case studies show ~400 man/hour savings per code
review

Remember: remove the subjective and move to the objective

Demonstrations• Example Showing JBuilder• Example Showing RAD Studio

20

michael.rozlog@embarcadero.com
http://blogs.embarcadero.com/michaelrozlog
22