Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in...
Transcript of Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in...
1
Can you read?
2
Refactoring
3
GOTO Conversion
4
Subroutine to ILE Procedure
5
Modernization & RefactoringImproving the Design of Code, Database and More!
6
Refactoring
7
Today’s Speaker
8
Refactoring
9
Business value of Refactoring? Eleni Stroulia
10
• about Refactoring/Modernization• previous refactoring events
• can you name them?• general principles• recognize code smell• ugly code can stay • recognize tradeoffs and obstacles to refactoring
11
12
13
What Happened?
14
Improve the Design of Existing Code
15
CISC to RISC
16
Four Digit Year
17
1956 5GB IBM Hard Drive
18
We is your code comfort?
19
Refactoring and DevOps Transition
• Lay the Foundation– Analyze your existing resources
• Skillset, methodology, existing tooling
• Identify "Champions"
– Pick tools that match your needs and experience• ...not necessarily those that have the largest visibility
– Document
– Review
– Begin to install back office tooling
• Make incremental Development changes– Start using RDi (if you aren't already)
– "Big Bang Refactoring or DevOps" not absolutely necessary• Instead, consider making changes as part of already-defined (and already
funded) projects
20
Start thinking in terms of "Objects"– Matches what "Distributed" (Java, C#, C++) developers expect
• Often very similar to Database UML
– Related objects become service programs (*SRVPGM)
– Each object becomes a module (*MODULE)
– Actions becomes exported procedures
– Can be easily scripted for testing
Development Transition - OO
21
Separate Business Logic from User Interface (Model-View-Controller)
– Model ≈ Reference File
– View = 5250 (+Web, Mobile, Eclipse, Client Server, ...)
– Controller = Module(s) (*MODULE)
Development Transition - MVC
22
CI does not work without scriptable test cases...
– Test Driven Development (xUnit overwhelmingly popular)
Development Transition - TDD
JUnit:
Customer cust = new Customer();
String[] location = {"665 Surf Terrace", "Wauconda", "IL"};
cust.setLocation(location);
Order order = new Order(cust);
boolean success = false;
try {
cust.delete();
} catch (Exception e) {
assertThat(e, is(CustomerHasOrdersException));
}
assertThat(success, is(true));
RPGUnit:
dcl-f orderF usage(*UPDATE:*DELETE);dcl-ds orderDs likerec(orderRec);
chain ('665 Surf Terrace' : 'Wauconda' : 'IL') orderRec orderDs;
assert (not %found : 'Record ("665 Surf Terrace", "Wauconda", "IL")' + 'should not be found');
23
Yes!
Maybe
No
Legend
OMG No!
24
• Convert RPGIII to ILE– No: GOTO; I-spec; O-spec; Cycle
– Free-form preferably• More readable/quicker changes (especially for new developers)
• Easier tracking (fewer diff lines)
• Tooling:– RDi
– H/S RPG Toolbox
– ARCAD RPG Converter for IBM i
• Convert subroutines to procedures (where appropriate)– Minimal usage of global variables
• Review /COPY usage– Fine for "macros" (e.g. sort) and copyright/version info
– Should never /COPY business logic into multiple programs
Development Transition - RPG
25
Break up Large Programs– Do multiple developers work on different parts of the same
program?• Multiple checkouts prevent feature promotion
• Resolving source conflicts (Sync) is the most difficult (and most costly) part of distributed development
– Are any of these true:• Do you have >10 levels of indentation?
• Is your source increment .01??
• Does the compiler sometimes crash when processing your source???– Have you already asked IBM to increase some limit so your program can compile?!?
– ...answering yes, probably means your program isn't modular...
Development Transition
26
Start thinking in terms of “Three Strikes your Out"– First time just do it-Nike
• Always fit into workflow to refactor opportunistically
– Second time you do something similar, wince at duplication but do it
anyway
– Third time you do something similar, you refactor
Rule of Three-Don Roberts
27
Some techniques
– Third time you do something similar, you refactor
– Before you add a new feature, Preparatory Refactoring
– Making code easier to understand, Comprehensive Refactoring
– Litter-Pickup, understand but doing it badly
– Experiment , refactoring and new feature in separate commits (changes)
– Naming provides clarity and understanding, SQL table
Rule of Three-Don Roberts
Smelly Slide-Fixed to Free-Form RPG
GOTO Conversion
GOTO Conversion
31
GOTO Conversion
CALLx Conversion
MOVEA Conversion
PLIST Conversion
KLIST Conversion
36
Not limited to just code-Database
– First time you do something, you refactor?
– Constraints-Database Centric Programming
– Performance
– Testing-Build Dependency-Concurrent Changes
– Surrogate-Religious War
– Naming provides clarity and understanding, SQL table
Rule of One-Some Speaker(Me)
Copyright Arcad Software 1992-2016 37Copyright Arcad Software 1992-2016 37
DDS to DDL conversion
You can transform
manually, buy a new
application or
Modernize/Refactor to
drive additional Code
transformation:
- Field Renaming
- Keyword management
- Object renaming
- Multi-member files
management
38
QuestionsWhat did you think?