Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Feature Requests
 Refactor by purpose and name

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
foxmuldr Posted - Jun 15 2016 : 10:14:40 AM
I've never seen the ability before, but it's something that could be beneficial. A co-worker brought up this issue in one of the applications he's working on. He finds that some developers use positives, and other developers use negatives, when creating flag variables. Some use "is active" (positive) and others use "is inactive" (negative). It's one of his biggest complaints.

So, suppose I have a negative variable form in an application I've inherited. The variable is called "isInactive". It's used about 200 places, so it's not easily manually refactored. But, I would really like to switch the variable around to be the positive form "isActive" so that it goes along with the rest of the application's design.

Would it be possible to add an ability to VAX which would find all references of that variable (as it does today), and then to go the step further and flip each usage's logic around to the opposite condition? In that way, a type of "refactoring by purpose and name" rather than just "refactoring by name," could be achieved?

For example:

bool isInactive;

    if (isInactive)
        // Do something


The above would become:

bool isActive;

    if (!isActive)
        // Do something


Best regards,
Rick C. Hodgin
4   L A T E S T    R E P L I E S    (Newest First)
foxmuldr Posted - Jun 24 2016 : 12:01:26 AM
quote:
Originally posted by feline

All sensible ideas, but also showing just how complex this could get, and how messy it might get. For now, we don't even have the basic "invert an if statement" feature up and running. Some form of confidence level is reasonable, and I already made a note of that idea when noting this on the case.

Certainly something to consider, but I am not sure if or when we might try this.



As I say, I've never seen it before. It would be a nice feature.

Best regards,
Rick C. Hodgin
feline Posted - Jun 23 2016 : 1:55:20 PM
All sensible ideas, but also showing just how complex this could get, and how messy it might get. For now, we don't even have the basic "invert an if statement" feature up and running. Some form of confidence level is reasonable, and I already made a note of that idea when noting this on the case.

Certainly something to consider, but I am not sure if or when we might try this.
foxmuldr Posted - Jun 15 2016 : 8:28:37 PM
quote:
Originally posted by feline

We have considered a related, simpler idea, inverting a specific if statement:

case=27848

I have put a note onto the case about this extension of the idea.

Here, it is the open ended nature of this that concerns me. If we can assume that the variable is only ever checked for true / false, you still need to think about:

IsInactive == false
false == IsInactive
IsInactive <> false

all of which are handlable. But what if it is used inside a much more complex if statement, where there are several conditions chained together?

What about other checks? What if this is used to control a while loop? Something like this, you need to have a lot of confidence in your automated code edits, and an awareness of possible edge cases.



My suggestion would be to assign a confidence level on each entry, and as with the Shift+Alt+R refactor display today with its checkmarks to choose or not choose the refactor on that item, extend the purpose refactor form to allow full source code editing on each line so the user can override the auto-suggested fixup.

You can also place the confidence level (either something generic like high, medium, low confidence, or an actual value) into a sortable column so they can be at the top or bottom of the list.

It might also be desirable to have a "Print" option to get a hard copy of the proposed list of changes for offline review, as sometimes it's easier to take a pencil and go through each one individually and mark it off, and then go and fixup the two or three that were invalid.

And if you really want to get fancy, you could add a feedback feature which allows the user to send back the original source code line, info VAX has about the variable type, what its proposed change was, and what it actually wound up being as per the user's edits, so that you can look for common patterns and extend your algorithm to handle those use cases.

Best regards,
Rick C. Hodgin
feline Posted - Jun 15 2016 : 7:44:43 PM
We have considered a related, simpler idea, inverting a specific if statement:

case=27848

I have put a note onto the case about this extension of the idea.

Here, it is the open ended nature of this that concerns me. If we can assume that the variable is only ever checked for true / false, you still need to think about:

IsInactive == false
false == IsInactive
IsInactive <> false

all of which are handlable. But what if it is used inside a much more complex if statement, where there are several conditions chained together?

What about other checks? What if this is used to control a while loop? Something like this, you need to have a lot of confidence in your automated code edits, and an awareness of possible edge cases.

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000