× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 8 May 2017 at 16:36, Jack Tucky <jacktucky@xxxxxxxxx> wrote:
I try to use RDI more and more everyday. I've never heard of refactoring.
I searched help and quick access. How can I find out what it does?

Before I answer your actual question, a point of information. RDi is
a little bit different to most of the IBM software that we're used to.
The developers have been tracking changes in release notes at
http://www-01.ibm.com/support/docview.wss?uid=swg27038481 The changes
aren't highlighted like in more traditional IBM manuals.

The refactoring capability was introduced with 9.5.1.1 in Dec 2016.
It is a direct result of the RDi community voting in the RFE (Request
For Enhancement) process - they hear us! RFE 31305 is where this got
started: http://www.ibm.com/developerworks/rfe/execute?use_case=viewRfe&CR_ID=31305
The documentation for this first step of refactoring is at
https://www.ibm.com/support/knowledgecenter/SSAE4W_9.5.1/com.ibm.etools.iseries.rse.doc/topics/refactor.html

Now that the dry stuff is over, what is refactoring? Refactoring is
the process, the art and science of changing a block of code without
altering the functionality of that block. Say what now? Why would
anyone in their right mind change code without, er, changing it? One
reason is to make it easier to read. Imagine a block of code that has
a bunch of comparisons in it. Say 'status' codes:

if status = 'A'
or status = 'J'
or status = '9'
then fld3 = 'D';

Yeah, lovely, am I right? In this case, because you now the database,
you know that these statuses mean 'deleted'. But they are different
sorts of 'deleted'. What if the code looked like this instead:

if status = DELETED_THIS_YEAR
or status = DELETED_LAST_YEAR
or status = PERMANENTLY_SUSPENDED
then fld3 = 'D';

One kind of refactoring (we don't have this yet) is to Extract a
Constant. You highlight the constant, refactor > extract constant and
the editor asks you what name you'd like, does the DCL-C for you and
changes the line you're on. Sweet, right? The code has been changed,
made more readable, but the functionality is still intact. It's nasty
to scan and replace all the instances of 'A' or '9'. If you like the
idea of Extract Constant, vote for
https://www.ibm.com/developerworks/rfe/execute?use_case=viewRfe&CR_ID=98365

I won't drone on about what we haven't got; look at these RFEs and
vote them up if you want more refactoring functionality:
https://www.ibm.com/developerworks/rfe/execute?use_case=viewRfe&CR_ID=98367
https://www.ibm.com/developerworks/rfe/execute?use_case=viewRfe&CR_ID=98369

What we do have, is the ability to rename a variable.

Ctrl-Shift-R on a variable will bring up a dialogue box that will ask
for the new name, and then RDi will go through the code and rename it
for me. Rename this way is way easier than scan and replace. Imagine
you have something like this:

if date >= start and date <= end;

Don't try a global replace of 'end' to 'end_date' because you'll catch
'end tag' 'endsr' 'legend' 'endif' 'enddo'... you get the idea. The
point though is that I can now use clearer names. I work in a lot of
older code. Code that has 6 character UPPER CASE field names; that
kind of old. It sure is nice to be able to convert that code to /free
with RDi and then refactor those names to something more readable than
L1TOT. Total what? Region_sales_dollars is way easier on what few
neurons I have that still fire!

Our Java and C brothers and sisters have had refactoring for some
time. They use it as part and parcel of agile programming, where
changes are made in rapid succession. Try this, Ms User wants is a
bit different? No problem, try this, and this and this. If you don't
refactor in that environment, you're left with a melange of ideas,
funny names and weird 'magic numbers' sprinkled everywhere. Having an
IDE that automates refactoring means that I can change my mind about
the name even after the code has been in production for a year.

Sweet!
--buck

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.