TS 68 JavaFX Refactoring

Refactoring

Author: Alexandr Scherbatiy
Version: 1.1
Last update: 25 September 2009
Introduction:
Comments:


Contents



Refactoring Ubrella issue: 173077

What Issues
Variable
name 172739
type
Function
name
argument 172147
return type
body
Sequence
name 172145
Package
name
D&D
Class
name 173259, 173252
attribute ,173243
function
attribute scope 173254
inheritance 172165
mixin
Operators
while 172751
for



Variable

  1. Name
    1. Type in the editor:

public var a = 10; public var b = a + 10;

    1. Refactor->Rename the a variable to c
    • Code should be compilable
    • The result should be
public var c = 10; public var b = c + 10;
  1. Type
    1. Type in the editor:

var a:A;

class A{}
    1. Refactor->Rename the A type of the a variable to B
    • Code should be compilable
    • The result should be
var a:B; class B{}



Function

  1. Name
    1. Type in the editor:

function f(x:Number):Number{ x * x}

    1. Refactor->Rename the f function to sqr
    • Code should be compilable
    • The result should be
function sqr(x:Number):Number{ x * x}
  1. Argument
    1. Type in the editor:

function sqr(x:Number):Number{ x * x}

    1. Refactor->Rename the x argument to y
    • Code should be compilable
    • The result should be
function sqr(y:Number):Number{ y * y}
  1. Return Type
    1. Type in the editor:

class A{} function f(a:A):A{ A{} }

    1. Refactor->Rename the A function return type to B
    • Code should be compilable
    • The result should be
class B{} function f(a:B):B{ B{} }



Sequence

  1. Name
    1. Type in the editor:

var seq = [1,2,3,4,5]; var sqr = for(n in seq) seq[[N | n]] * seq[N];

    1. Refactor->Rename the seq sequence to s
    • Code should be compilable
    • The result should be
var s = [1,2,3,4,5]; var sqr = for(n in s) s[[N | n]] * s[N];



Package

  1. Name
    1. Create a package
    2. Create A JavaFX class under the package
package a; public class A { }
    1. Refactor->Rename the a package to b
    • Code should be compilable
    • The A class should have the b package
package b; public class A { }
  1. Drag And Drop
    1. Create a package
    2. Create A JavaFX class under the package
package a; public class A { }
    1. Create b package
    2. Drag and drop the A class to the b package
    • Code should be compilable
    • The A class should have the b package
package b; public class A { }
  1. Default package
    1. Have a JavaFX class in any package
    2. Refactor -> Move it into empty package
    • Class is moved without any error. There is no package line in source code


Class

  1. Name
    1. Type in the editor:

class A{}; var a = A{};

function f(a:A):A { A{} }

    1. Refactor->Rename the A class to B
    • Code should be compilable
    • The result should be
class B{}; var a = B{}; function f(a:B):B { B{} }
  1. Attribute name
    1. Type in the editor:

class A{

   public var attr:String;

};

var a = A{ attr: "Hello World" };

println(a.attr);

    1. Refactor->Rename the attr attribute name to attr2
    • Code should be compilable
    • The result should be
class A{ public var attr2:String; }; var a = A{ attr2: "Hello World" }; println(a.attr2);
  1. Attribute Type
    1. Type in the editor:

class A{

   public var attr:A;

};

var a = A{ attr: A{} };

    1. Refactor->Rename the A type of the attr_ attribute to B__
    • Code should be compilable
    • The result should be
class B{ public var attr:B; }; var a = B{ attr: B{} };
  1. Attribute Default Value
    1. Type in the editor:

class A{

   public var attr:A = A{};

};

var a = A{ attr: A{} };

    1. Refactor->Rename the A default value of the attr_ attribute to B__
    • Code should be compilable
    • The result should be
class B{ public var attr:B = B{}; }; var a = B{ attr: B{} };
  1. Inheritence
    1. Type in the editor:

class A{} class B extends A{}

    1. Refactor->Rename the A class to D
    • Code should be compilable
    • The result should be
class D{} class B extends D{}
  1. Mixin
    1. Type in the editor:

class A{} mixin class M{} class B extends A, M{}

    1. Refactor->Rename the M class to N
    • Code should be compilable
    • The result should be
class A{} mixin class N{} class B extends A, N{}




Operators

  1. While loop
    1. Type in the editor:

var f = true;

while(f){

   f = not f;

}

    1. Refactor->Rename the f variable to g in the 'while(f){' line
    • Code should be compilable
    • The result should be
var g = true; while(g){ g = not g; }
  1. For loop
    1. Type in the editor:

var s = [1,2,3,4,5]; var t = for(n in s) s[N] * indexof n;

    1. Refactor->Rename the n loop variable to m
    • Code should be compilable
    • The result should be
var s = [1,2,3,4,5]; var t = for(m in s) s[M] * indexof m;



-- Main.AlexandrScherbatiy - 22 Sep 2009

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo