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.
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Software Archaeology and Code Refactoring with Rational Developer for System z (RDz)
1.
2. 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
3. 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
6. 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
7. 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
9. 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
10. 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
11. 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
12. 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
15. 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
19. 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
21. 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
24. 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
25. 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
26. 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
28. 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
30. 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.
33. 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.
36. 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
39. 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
40. 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
41. 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
42. 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
43. 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
intsw*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
46. 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
49. 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
50. 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
51. www.strongback.us
COBOL & PL/I Rules
• Industry standard best practices
– Naming
– Performance
– Structure of programs
51
52. 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.
56. 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