Issue Details (XML | Word | Printable)

Key: FDT-2142
Type: Featurerequest Featurerequest
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: FDT Team
Reporter: Oliver Groulx
Votes: 1
Watchers: 2

If you were logged in you would be able to see more operations.

Refactoring : Modify parameter list

Created: 02/Jun/11 05:46 PM   Updated: 19/Jan/16 04:58 PM
Component/s: Refactoring
Affects Version/s: FDT 4.5.2
Fix Version/s: FDT
Security Level: public

Time Tracking:
Not Specified

Review Type: Review by Product Owner

 Description  « Hide
Sometimes, you may want to change the parameter list of a function, which will potentially break any code using this function. Possible modifications include :

1. Reordering
Changing the order of parameters changes the order of arguments on the caller side. If the parameter is optional, it must stay within the optional group and only caller using this parameter will be affected.

2. Removing parameters
Removing a parameter will delete the argument expression on the caller side. If the parameter was optional, only caller using this parameter will be affected.

3. Adding non-optional parameters
Adding a non-optional parameter will add a default value (0, null, etc depending on the type) as an argument on the caller side.

4. Converting from optional to required
Similar to adding a parameter (default value on the caller side), except no change is made if there was already an argument passed. The parameter is also moved next to the last required parameter if necessary.

5. Converting from required to optional
The parameter is moved as the first optional parameter and a dialog box could ask for a default value.

This feature could be implemented as a simple dialog box with two lists, one for required and one for optional. Those lists can be modified freely (reorder, delete, add) and two buttons could provide the functionality of converting from one parameter type to the other (something like "move to optional list" and "move to required list").

The rest (...) parameter can be problematic when it needs to be moved (adding and removing parameters). When adding a parameter before the rest parameter, callers must provide a value for this parameter, either they already had a value with the right type but was previously passed to the rest argument, or pass a default value. When removing a parameter, no modification needs to be done on the caller side, since overflowing arguments will be caught by the rest parameter.

Two cases of adding a new parameters with rest
{{function fun(a:int, => function fun (a:int, b:int,
fun(1, 2, 3); => fun(1, 2, 3);}}

No modifications needs to be done here since the types matches.

{{function fun(a:int, => function fun (a:int, b:String,
fun(1, 2, 3) => fun(1, "", 3) }}

Argument 2 is replace with a default value of the right type.

removing a parameter with rest
{{function fun(a:int, b:int, => function fun (a:int,
fun(1, 2, 3) => fun(1, 2, 3) }}

No modifications when removing a parameter.

 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Stephanie Swiderski added a comment - 01/Dec/14 01:02 PM
The Change Function Signature refactoing
can handle all of these requests.