56

Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

Embed Size (px)

DESCRIPTION

Presented at the North Florida Rational User Group, March 25, 2014 Refactoring is a rather new term in the COBOL world. It is something that the Java, .NET, PHP, and Python developers have been doing this for years. In the COBOL world, there are countless programs that appear to have stopped maturing once they've gone into production. Refactoring can make your applications more manageable, and stable over time. Software archaeology is the process by which you discover what you've got, what you've forgotten, and where code originates. In this meeting, we'll how a z/OS developer can use these strategies with RDz to improve their code, and their productivity using RDz. We'll focus on the new features of the COBOL and PL/I editors, performance hierarchy diagrams, code generation wizards, the Software Analyzer code review features, and MVS tooling that allows the developer to work with partitioned and sequential datasets, VSAM files, and GDG's.

Citation preview

Page 1: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)
Page 2: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

About Us: Strongback Consulting

• IBM Advanced Business Partner

– Rational, WebSphere, Lotus, Information Management SVP certified

– Strongly focused on Enterprise Modernization and application lifecycle management

– Key Industries Served: Finance, Insurance, Healthcare, Manufacturing, Government

– Rational Design Partner for HATS and other Rational enterprise modernization technologies

Discover us at: http://www.strongback.us

Subscribe to us at http://feeds.feedburner.com/StrongbackConsulting Socialize with us on Facebook & LinkedIn http://www.facebook.com/StrongbackConsulting http://www.linkedin.com/company/290754

Page 3: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

Agenda

• The view from the programmer analyst

• How to conduct archaeology on your source code

• Analytic tooling within Rational Developer for System z

3

Page 4: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us 4

A day in the life of a software archaeologist

Page 5: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

What the code reminds you of….

5

Page 6: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

Definition: White Elephant

6

A white elephant is an idiom for a valuable but burdensome possession of which its owner cannot dispose and whose cost (particularly cost of upkeep) is out of proportion to its usefulness or worth. Source: wikipedia.org

Page 7: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

The white elephant: 12,000 lines of spaghetti

• Where do you start?

• Unpredictable abends

• Hard to navigate

• Difficult to create a “mental map”

• Potentially lots of dead code

• Out of date comments

7

Page 8: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us 8

Page 9: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

Rational Developer for System z v9.0 The modern development environment for the modern mainframe

“Working across several source code files and copy books– and

debugging at the same time!– is game changing.”

COBOL Application Programmer

9

Modern IDE features to pull-in new developers to System z application development with rich, modern development for COBOL, PL/I, Java, JCL, CICS, IMS, Batch, Stored Procedure Powerful, easy to use editors with immediate, inline assistance and navigation of host-based resources Build & debug across complex application layers and boundaries Design, code, build, test, and deploy mobile apps that run on a wide variety of mobile platforms; Quickly refactor and extend existing back-end services and data to new mobile UIs Code analysis that warns you about poorly written code

What’s new:

•Support for CICS TS 5.1 & optimized COBOL v5

compiler

•Enhanced JCL editing

•Automate unit testing with zUnit

•Headless code review and code coverage

Page 10: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us 10

Modern application development across platforms Upgrade to modern Eclipse-based tools to develop and maintain enterprise applications spanning multiple platforms, languages and technologies

Rational Developer for System z

Rational Developer for zEnterprise Increase Productivity

Eclipse-based open source IDE

More attractive to recent university hires than legacy z/OS tooling

More relevant information is readily available

Speeds development with specialized editors and code generation wizards

Code assist, syntax highlighting, quick fixes, outline view

Accelerate application modernization

Enable CICS and IMS appls for Web Services / SOA

Lower skill requirements for new hires to code to complex architectures (e.g. Web 2.0)

Reduce Training Costs in adopting System z environment

Provides interactive access to z/OS for development, debug, job generation, job submission, monitoring and command execution

Free up mainframe for production workload

Workstation syntax checking reduces host workload

Unit Test feature offloads additional workload

10

Page 11: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us 11

IDE Efficiency Benchmarks An IBM productivity study concluded that RDz significantly improves productivity as compared to

ISPF

• 100 common (daily) ISPF tasks used during maintenance and support assignments

– ISPF workflow translated (click-for-click) to RDz development

– Project participants believed they were trying to find gaps between RDz and ISPF functionality

• Mix of experienced (veteran) ISPF programmers and new-hire developers

• Assumption was that only new-hire developers would be more productive

– This turned out to be false

% less time to complete System z application development tasks using RDz vs. ISPF

Inexperienced ISPF Users Experienced ISPF Users

Similar results achieved by Financial Services customers

Page 12: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us 12 12

RD z – More than just a pretty editor, Its an Integrated Development Environment

• Rich Functionality

– Sophisticated application analysis and quality governance

– Extensive programming assists and wizards

– Seamless access to ISPF and eclipse-style editors

– Operational navigation between the integrated components

• Extensive functional integration

– Application Lifecycle Management solution - ISDz

– Problem Determination tools

– Mainframe security facilities

– Source Control Management products

– Any 3rd Party/OEM tools on the Eclipse platform

• World-wide partners and extensive Eco-system

Page 13: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us 13

Page 14: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us 14

Page 15: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

Viewing down into the pit

Program Control Flow Diagram:

• Birds Eye view of source

• Treat it like a blueprint

• Navigable and linked to source

• Export and save for documentation

15

Page 16: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

Digging sideways – Performance Hierarchy

16

Conditional

Statements

Perform Until

Statements

Potential

program fall thru

Page 17: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

Finding nuggets of information

17

Page 18: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

Navigation with Outline View

18

Sort

alphabetically

Hide

Divisions

Click on a

paragraph to

navigate to it

in source

view

Page 19: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

Find Dialog

• CTRL + F to bring up dialog

• Can search case sensitive, forward, backward, on all code, or just that selected.

• Regular expressions

– Content assist available to help build a search query

19

Page 20: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

Format source automagically

20

You are no longer limited to tedious ISPF functions for indenting code!

Makes maintenance easier for all who follow you.

Page 21: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

Identify Unreachable Code

• Finds Dead Code

– Source → Find Unreachable Code

• Results mark lines or paragraphs that will never get called

• Mark them out with Source→ Toggle Comments, then delete when confirmed

21

Page 22: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us 22

Page 23: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us 23

Page 24: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

Editing Source Code

• System z LPEX Editor

– Can emulate ISPF line commands & functions

– Generic editor for all source

• Specific source editors to give a richer feel

– COBOL, PL/I

– C/C++

– JCL

24

Page 25: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

Hovers

• Hover mouse over a variable, or perform statement

• Popup displays the declaration

• Press F2 to make the window retain focus

25

Page 26: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

Hover over a Copy Statement

• Hold down CNTL key and hover over the copybook name

• Copybook name becomes a hyperlink

– click to open

– Also opens a hover window showing the contents of the window

26

SYSLIB property

group must be set for

this to work

Page 27: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

Content Assist

• Shows list of valid variables, or language structures

• Intelligence to suggest SQL within an EXEC statement

27

Page 28: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

Quick Fix

• Margin area shows warnings and errors

• Quick fix suggestions show as a light bulb

• Parser is able to suggest fixes when clicked

• Click on the suggestion to make the change

28

Page 29: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

• Enable against COBOL 4.2, or 5.1 (the latest version)

• Make checks for EXEC statements

29

Real Time Syntax Checking

Page 30: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

Refactoring

30

Refactoring: make system-wide code changes without affecting the behavior of the program. Refactoring commands are available from the context menus of several views (e.g. Project Explorer, Outline) and editors. Many "apparently simple" commands, such as Move and Rename, are actually refactoring operations, since moving and renaming elements often require changes in dependent files. • Extract a function, constant or local variable • Rename a method, variable or class • Hide a method signature Operations can be previewed for all of the changes resulting from a refactoring action before you choose to carry them out.

Page 31: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

Extract Constant (C/C++)

• Improve performance, and avoid duplicate strings

31

Page 32: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

Renaming Variables

• Easily rename a variable throughout your code

– More accurate than find/replace

– Make variables easier to understand

32

Page 33: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

Source Actions

33

Use the Source menu to perform many actions to modify, remove or generate code automatically. • Toggle a line or block as a comment; on or off. • Format entire source files or fragments. • Correct Indentation • Implement getters & setters • Sort lines

The Source menu can be accessed from many context views such as in the COBOL, and C/C++ editor.

Page 34: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

Toggle Commenting on and off

• Toggle single line to comment on/off

• Toggle a block of lines to comment on/off

34

Page 35: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

Sorting Lines (C/C++)

• Make content easier to read by alphabetizing your fields

35

Page 36: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

Surround With

• Easily move source into a conditional statement

– for loop

– do/while

– if/else

– try/catch

• Highlight the desired code, right click -> Surround With

– also ATL+SHIFT+Z

Page 37: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us 37

Page 38: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us 38

Page 39: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

Searching

• Multiple different types of search in the product

– Remote z/OS Search

– Data Model Search

– File system search (local)

– language based search (C/C++, Java, COBOL, etc)

• Called from the search bar

• Search from the context menu

• Or a keyboard shortcut CNTL + H

Page 40: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

Remote z/OS Search

• Remote z/OS Search uses the RDz daemon on the server to scan MVS assets

• Can scan through specific filters

• Can scan selected PDS’s and members

• Can also scan offline & migrated datasets

40

Page 41: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

Search Types

• By Partitioned Dataset Name

– search by name of the PDS only

• By Sequential Dataset

– Can search by name, or within the content

• By Dataset member

– Can search by name, or within the content

– Within name or content, can also search using regular expressions

41

Page 42: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

Search Contexts

• Searches only within a single LPAR (does not cross multiple systems)

• Search on existing filters

• Search within selected contexts

– Could be a filter, a dataset, a sequential dataset, or multiple selected datasets

42

Page 43: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

Using Regular Expressions to Search

• For example

custRec|tranRec

• This will search and find any line in the search context that has either custRec, or tranRec

– The pipe symbol ‘|’ acts as an “or” statement

• Another example

int\s\w*\s=

• This will find all integer instantiations with in the search context

– \w* = any word char repeated more than once

– \s = any whitespace character

– int and = are treated as normal characters

43

Page 44: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

Sub-setting search results

• Sort columns ascending or descending

• Expand source members to see lines where text was found

• Filter result list within the client

44

Page 45: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

Search Results

45

Sortable

Columns

Source

Member

Lines in

source

where text

was found

Filter to sub

set results

Expand /

Collapse

results

Save results

to Favorites

Stop Search Edit query

parameters

View

Menu

Remove

matches

from view

Page 46: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

The My Favorites Folder

• Shows saved search queries

– Great for ready access to frequently searched phrases

• Save the search from the view menu

• Saved searches can be edited, and run again

46

Page 47: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us 47

Page 48: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us 48

Page 49: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

What is Software /Analyzer Code Review?

• Provides a means for you to enforce shop coding standards and best practices

• Available for COBOL programs opened from:

– Remote Systems Explorer

– Local Workstation Projects – including a PDS downloaded to a local project

– z/OS Projects/MVS Subprojects

• Easy to use:

– Context-menu accessible - Create custom rule sets configuration based on in-the-box COBOL rules

– More requirements (from customers) are encouraged/gladly accepted

Page 50: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

Features

• Somewhat customizable:

– In-the-box rules customizable through Preferences/Configurations for rules

• Application Code Review

– Expands on existing Java code review

– Check for COBOL standards deviations in the editor

– Run reports on standards compliance and trends

– Improve application quality and compliance

50

Page 51: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

COBOL & PL/I Rules

• Industry standard best practices

– Naming

– Performance

– Structure of programs

51

Page 52: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us 52

Results

• Depending on which kind of analysis you are doing, the results view may differ. Some results views, like the one provided by Java code review, support viewing results in more than one format (a table or a tree, for example).

• If you right-click on a result, you can perform special tasks, such as viewing the source code where the problem occurred or "quick fixing" the problem with an automatic result.

Page 53: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us 53

Page 54: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

Resources

• Check out all our links for our presentations, including this one

• http://delicious.com/strongback/rdz

54

Page 55: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us 55

Questions?

Page 56: Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)

www.strongback.us

Socialize with us on Facebook & LinkedIn http://www.facebook.com/StrongbackConsulting http://www.linkedin.com/company/290754

Subscribe to us at http://feeds.feedburner.com/StrongbackConsulting

Discover us at: http://www.strongback.us

Watch Us at Youtube http://www.youtube.com/user/strongbackconsulting https://vimeo.com/user7519232

Call us at: 386-232-8746