Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in...

38
1 Can you read?

Transcript of Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in...

Page 1: Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in terms of “Three Strikes your Out" –First time just do it-Nike • Always fit into

1

Can you read?

Page 2: Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in terms of “Three Strikes your Out" –First time just do it-Nike • Always fit into

2

Refactoring

Page 3: Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in terms of “Three Strikes your Out" –First time just do it-Nike • Always fit into

3

GOTO Conversion

Page 4: Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in terms of “Three Strikes your Out" –First time just do it-Nike • Always fit into

4

Subroutine to ILE Procedure

Page 5: Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in terms of “Three Strikes your Out" –First time just do it-Nike • Always fit into

5

Modernization & RefactoringImproving the Design of Code, Database and More!

Page 6: Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in terms of “Three Strikes your Out" –First time just do it-Nike • Always fit into

6

Refactoring

Page 7: Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in terms of “Three Strikes your Out" –First time just do it-Nike • Always fit into

7

Today’s Speaker

Page 8: Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in terms of “Three Strikes your Out" –First time just do it-Nike • Always fit into

8

Refactoring

Page 9: Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in terms of “Three Strikes your Out" –First time just do it-Nike • Always fit into

9

Business value of Refactoring? Eleni Stroulia

Page 10: Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in terms of “Three Strikes your Out" –First time just do it-Nike • Always fit into

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

Page 11: Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in terms of “Three Strikes your Out" –First time just do it-Nike • Always fit into

11

Page 12: Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in terms of “Three Strikes your Out" –First time just do it-Nike • Always fit into

12

Page 13: Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in terms of “Three Strikes your Out" –First time just do it-Nike • Always fit into

13

What Happened?

Page 14: Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in terms of “Three Strikes your Out" –First time just do it-Nike • Always fit into

14

Improve the Design of Existing Code

Page 15: Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in terms of “Three Strikes your Out" –First time just do it-Nike • Always fit into

15

CISC to RISC

Page 16: Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in terms of “Three Strikes your Out" –First time just do it-Nike • Always fit into

16

Four Digit Year

Page 17: Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in terms of “Three Strikes your Out" –First time just do it-Nike • Always fit into

17

1956 5GB IBM Hard Drive

Page 18: Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in terms of “Three Strikes your Out" –First time just do it-Nike • Always fit into

18

We is your code comfort?

Page 19: Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in terms of “Three Strikes your Out" –First time just do it-Nike • Always fit into

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

Page 20: Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in terms of “Three Strikes your Out" –First time just do it-Nike • Always fit into

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

Page 21: Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in terms of “Three Strikes your Out" –First time just do it-Nike • Always fit into

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

Page 22: Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in terms of “Three Strikes your Out" –First time just do it-Nike • Always fit into

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');

Page 23: Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in terms of “Three Strikes your Out" –First time just do it-Nike • Always fit into

23

Yes!

Maybe

No

Legend

OMG No!

Page 24: Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in terms of “Three Strikes your Out" –First time just do it-Nike • Always fit into

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

Page 25: Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in terms of “Three Strikes your Out" –First time just do it-Nike • Always fit into

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

Page 26: Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in terms of “Three Strikes your Out" –First time just do it-Nike • Always fit into

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

Page 27: Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in terms of “Three Strikes your Out" –First time just do it-Nike • Always fit into

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

Page 28: Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in terms of “Three Strikes your Out" –First time just do it-Nike • Always fit into

Smelly Slide-Fixed to Free-Form RPG

Page 29: Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in terms of “Three Strikes your Out" –First time just do it-Nike • Always fit into

GOTO Conversion

Page 30: Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in terms of “Three Strikes your Out" –First time just do it-Nike • Always fit into

GOTO Conversion

Page 31: Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in terms of “Three Strikes your Out" –First time just do it-Nike • Always fit into

31

GOTO Conversion

Page 32: Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in terms of “Three Strikes your Out" –First time just do it-Nike • Always fit into

CALLx Conversion

Page 33: Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in terms of “Three Strikes your Out" –First time just do it-Nike • Always fit into

MOVEA Conversion

Page 34: Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in terms of “Three Strikes your Out" –First time just do it-Nike • Always fit into

PLIST Conversion

Page 35: Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in terms of “Three Strikes your Out" –First time just do it-Nike • Always fit into

KLIST Conversion

Page 36: Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in terms of “Three Strikes your Out" –First time just do it-Nike • Always fit into

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)

Page 37: Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in terms of “Three Strikes your Out" –First time just do it-Nike • Always fit into

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

Page 38: Can you read? - LISUGlisug.org/presentations/Modernizartion and Refactoring.pdfStart thinking in terms of “Three Strikes your Out" –First time just do it-Nike • Always fit into

38

QuestionsWhat did you think?