TS 69 JavaFX Refactoring

(Difference between revisions)
(Refactoring)
(Refactoring)
Line 14: Line 14:
----
----
 +
====Variable====
====Variable====
====Variable====
# {{testcase|Name}}
# {{testcase|Name}}
-
## Type in the editor:  
+
* Type in the editor:  
<pre>
<pre>
public var a = 10;
public var a = 10;
public var b = a + 10;
public var b = a + 10;
</pre>
</pre>
-
## Refactor->Rename the '''a''' variable to '''c'''
+
* Refactor->Rename the '''a''' variable to '''c'''
-
#* {{result|Code should be compilable}}
+
** {{result|Code should be compilable}}
-
#* {{result|The result should be}} <pre>
+
** {{result|The result should be}} <pre>
public var c = 10;
public var c = 10;
public var b = c + 10;
public var b = c + 10;
</pre>
</pre>
# '''Type'''
# '''Type'''
-
## Type in the editor:  
+
* Type in the editor:  
<pre>
<pre>
var a:A;
var a:A;
class A{</pre>}
class A{</pre>}
-
## Refactor->Rename the '''A''' type of the '''a''' variable to '''B'''
+
* Refactor->Rename the '''A''' type of the '''a''' variable to '''B'''
-
#* {{result|Code should be compilable}}
+
** {{result|Code should be compilable}}
-
#* {{result|The result should be}}  
+
** {{result|The result should be}}  
<pre>
<pre>
var a:B;
var a:B;
Line 46: Line 47:
# {{testcase|Name}}
# {{testcase|Name}}
-
## Type in the editor:  
+
* Type in the editor:  
<pre>
<pre>
function f(x:Number):Number{ x * x}  
function f(x:Number):Number{ x * x}  
</pre>
</pre>
-
## Refactor->Rename the '''f''' function to '''sqr'''
+
* Refactor->Rename the '''f''' function to '''sqr'''
-
#* {{result|Code should be compilable}}
+
** {{result|Code should be compilable}}
-
#* {{result|The result should be}}  
+
** {{result|The result should be}}  
<pre>
<pre>
function sqr(x:Number):Number{ x * x}
function sqr(x:Number):Number{ x * x}
</pre>
</pre>
# {{testcase|Argument}}
# {{testcase|Argument}}
-
## Type in the editor:  
+
* Type in the editor:  
<pre>
<pre>
function sqr(x:Number):Number{ x * x}
function sqr(x:Number):Number{ x * x}
</pre>
</pre>
-
## Refactor->Rename the '''x''' argument to '''y'''
+
* Refactor->Rename the '''x''' argument to '''y'''
-
#* {{result|Code should be compilable}}
+
** {{result|Code should be compilable}}
-
#* {{result|The result should be}}  
+
** {{result|The result should be}}  
<pre>
<pre>
function sqr(y:Number):Number{ y * y}
function sqr(y:Number):Number{ y * y}
</pre>
</pre>
# {{testcase|Return Type}}
# {{testcase|Return Type}}
-
## Type in the editor:  
+
* Type in the editor:  
<pre>
<pre>
class A{}
class A{}
function f(a:A):A{ A{} }
function f(a:A):A{ A{} }
</pre>
</pre>
-
## Refactor->Rename the '''A''' function return type to '''B'''
+
* Refactor->Rename the '''A''' function return type to '''B'''
-
#* {{result|Code should be compilable}}
+
** {{result|Code should be compilable}}
-
#* {{result|The result should be}}  
+
** {{result|The result should be}}  
<pre>
<pre>
class B{}
class B{}
Line 87: Line 88:
# {{testcase|Name}}
# {{testcase|Name}}
-
## Type in the editor:  
+
* Type in the editor:  
<pre>
<pre>
var seq = [1,2,3,4,5];
var seq = [1,2,3,4,5];
var sqr = for(n in seq) seq[[N | n]] * seq[N];
var sqr = for(n in seq) seq[[N | n]] * seq[N];
</pre>
</pre>
-
## Refactor->Rename the '''seq''' sequence to '''s'''
+
* Refactor->Rename the '''seq''' sequence to '''s'''
-
#* {{result|Code should be compilable}}
+
** {{result|Code should be compilable}}
-
#* {{result|The result should be}}  
+
** {{result|The result should be}}  
<pre>
<pre>
var s = [1,2,3,4,5];
var s = [1,2,3,4,5];
Line 106: Line 107:
# {{testcase|Name}}
# {{testcase|Name}}
-
## Create '''a''' package
+
* Create '''a''' package
-
## Create '''A''' JavaFX class under the package  
+
* Create '''A''' JavaFX class under the package  
<pre>
<pre>
package a;
package a;
Line 115: Line 116:
}
}
</pre>
</pre>
-
## Refactor->Rename the '''a''' package to '''b'''
+
* Refactor->Rename the '''a''' package to '''b'''
-
#* {{result|Code should be compilable}}
+
** {{result|Code should be compilable}}
-
#* {{result|The '''A''' class should have the '''b''' package}}  
+
** {{result|The '''A''' class should have the '''b''' package}}  
<pre>
<pre>
package b;
package b;
Line 126: Line 127:
</pre>
</pre>
# {{testcase|Drag And Drop }}
# {{testcase|Drag And Drop }}
-
## Create '''a''' package
+
* Create '''a''' package
-
## Create '''A''' JavaFX class under the package  
+
* Create '''A''' JavaFX class under the package  
<pre>
<pre>
package a;
package a;
Line 135: Line 136:
}
}
</pre>
</pre>
-
## Create '''b''' package
+
* Create '''b''' package
-
## Drag and drop the '''A''' class to the '''b''' package
+
* Drag and drop the '''A''' class to the '''b''' package
-
#* {{result|Code should be compilable}}
+
** {{result|Code should be compilable}}
-
#* {{result|The '''A''' class should have the '''b''' package}}  
+
** {{result|The '''A''' class should have the '''b''' package}}  
<pre>
<pre>
package b;
package b;
Line 147: Line 148:
</pre>
</pre>
# {{testcase|Default package}}
# {{testcase|Default package}}
-
## Have a JavaFX class in any package
+
* Have a JavaFX class in any package
-
## Refactor -> Move it into empty package
+
* Refactor -> Move it into empty package
-
#* {{result|Class is moved without any error. There is no package line in source code}}
+
** {{result|Class is moved without any error. There is no package line in source code}}
<br>
<br>
Line 156: Line 157:
# {{testcase|Name}}
# {{testcase|Name}}
-
## Type in the editor:  
+
* Type in the editor:  
<pre>
<pre>
class A{};
class A{};
Line 163: Line 164:
function f(a:A):A { A{} }
function f(a:A):A { A{} }
</pre>
</pre>
-
## Refactor->Rename the '''A''' class to '''B'''
+
* Refactor->Rename the '''A''' class to '''B'''
-
#* {{result|Code should be compilable}}
+
** {{result|Code should be compilable}}
-
#* {{result|The result should be}}  
+
** {{result|The result should be}}  
<pre>
<pre>
class B{};
class B{};
Line 173: Line 174:
</pre>
</pre>
# {{testcase|Attribute name }}
# {{testcase|Attribute name }}
-
## Type in the editor:  
+
* Type in the editor:  
<pre>
<pre>
class A{
class A{
Line 183: Line 184:
println(a.attr);
println(a.attr);
</pre>
</pre>
-
## Refactor->Rename the '''attr''' attribute name to '''attr2'''
+
* Refactor->Rename the '''attr''' attribute name to '''attr2'''
-
#* {{result|Code should be compilable}}
+
** {{result|Code should be compilable}}
-
#* {{result|The result should be}}  
+
** {{result|The result should be}}  
<pre>
<pre>
class A{
class A{
Line 196: Line 197:
</pre>
</pre>
# {{testcase|Attribute Type}}
# {{testcase|Attribute Type}}
-
## Type in the editor:  
+
* Type in the editor:  
<pre>
<pre>
class A{
class A{
Line 204: Line 205:
var a = A{ attr: A{} };
var a = A{ attr: A{} };
</pre>
</pre>
-
## Refactor->Rename the '''A''' type of the '''attr_ attribute to '''B__
+
* Refactor->Rename the '''A''' type of the '''attr_ attribute to '''B__
-
#* {{result|Code should be compilable}}
+
** {{result|Code should be compilable}}
-
#* {{result|The result should be}}  
+
** {{result|The result should be}}  
<pre>
<pre>
class B{
class B{
Line 215: Line 216:
</pre>
</pre>
# {{testcase|Attribute Default Value}}
# {{testcase|Attribute Default Value}}
-
## Type in the editor:  
+
* Type in the editor:  
<pre>
<pre>
class A{
class A{
Line 223: Line 224:
var a = A{ attr: A{} };
var a = A{ attr: A{} };
</pre>
</pre>
-
## Refactor->Rename the '''A''' default value of the '''attr_ attribute to '''B__
+
* Refactor->Rename the '''A''' default value of the '''attr_ attribute to '''B__
-
#* {{result|Code should be compilable}}
+
** {{result|Code should be compilable}}
-
#* {{result|The result should be}}  
+
** {{result|The result should be}}  
<pre>
<pre>
class B{
class B{
Line 234: Line 235:
</pre>
</pre>
# {{testcase|Inheritence}}
# {{testcase|Inheritence}}
-
## Type in the editor:  
+
* Type in the editor:  
<pre>
<pre>
class A{}
class A{}
class B extends A{}
class B extends A{}
</pre>
</pre>
-
## Refactor->Rename the '''A''' class to '''D'''
+
* Refactor->Rename the '''A''' class to '''D'''
-
#* {{result|Code should be compilable}}
+
** {{result|Code should be compilable}}
-
#* {{result|The result should be}}  
+
** {{result|The result should be}}  
<pre>
<pre>
class D{}
class D{}
Line 247: Line 248:
</pre>
</pre>
# {{testcase|Mixin}}
# {{testcase|Mixin}}
-
## Type in the editor:  
+
* Type in the editor:  
<pre>
<pre>
class A{}
class A{}
Line 253: Line 254:
class B extends A, M{}
class B extends A, M{}
</pre>
</pre>
-
## Refactor->Rename the '''M''' class to '''N'''
+
* Refactor->Rename the '''M''' class to '''N'''
-
#* {{result|Code should be compilable}}
+
** {{result|Code should be compilable}}
-
#* {{result|The result should be}}  
+
** {{result|The result should be}}  
<pre>
<pre>
class A{}
class A{}
Line 270: Line 271:
# {{testcase|While loop}}
# {{testcase|While loop}}
-
## Type in the editor:  
+
* Type in the editor:  
<pre>
<pre>
var f = true;
var f = true;
Line 278: Line 279:
}
}
</pre>
</pre>
-
## Refactor->Rename the '''f''' variable to '''g''' in the 'while(f){' line
+
* Refactor->Rename the '''f''' variable to '''g''' in the 'while(f){' line
-
#* {{result|Code should be compilable}}
+
** {{result|Code should be compilable}}
-
#* {{result|The result should be}}  
+
** {{result|The result should be}}  
<pre>
<pre>
var g = true;
var g = true;
Line 289: Line 290:
</pre>
</pre>
# {{testcase|For loop}}
# {{testcase|For loop}}
-
## Type in the editor:  
+
* Type in the editor:  
<pre>
<pre>
var s = [1,2,3,4,5];
var s = [1,2,3,4,5];
var t = for(n in s) s[N] * indexof n;
var t = for(n in s) s[N] * indexof n;
</pre>
</pre>
-
## Refactor->Rename the '''n''' loop variable to '''m'''  
+
* Refactor->Rename the '''n''' loop variable to '''m'''  
-
#* {{result|Code should be compilable}}
+
** {{result|Code should be compilable}}
-
#* {{result|The result should be}}  
+
** {{result|The result should be}}  
<pre>
<pre>
var s = [1,2,3,4,5];
var s = [1,2,3,4,5];

Revision as of 10:30, 4 August 2010

Refactoring

Author: Alexandr Scherbatiy
Version: 1.2
Last update: 4 August 2010
Introduction:
Comments:


Contents


Refactoring Ubrella issue: 173077


Variable

Variable

  1. Name
  • Type in the editor:
public var a = 10;
public var b = a + 10;
  • 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
  • Type in the editor:
var a:A;
class A{
}
  • 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
  • Type in the editor:
function f(x:Number):Number{ x * x} 
  • Refactor->Rename the f function to sqr
    • Code should be compilable
    • The result should be
function sqr(x:Number):Number{ x * x}
  1. Argument
  • Type in the editor:
function sqr(x:Number):Number{ x * x}
  • 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
  • Type in the editor:
class A{}
function f(a:A):A{ A{} }
  • 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
  • Type in the editor:
var seq = [1,2,3,4,5];
var sqr = for(n in seq) seq[[N | n]] * seq[N];
  • 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
  • Create a package
  • Create A JavaFX class under the package
package a;

public class A {

}
  • 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
  • Create a package
  • Create A JavaFX class under the package
package a;

public class A {

}
  • Create b package
  • 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
  • Have a JavaFX class in any package
  • Refactor -> Move it into empty package
    • Class is moved without any error. There is no package line in source code


Class

  1. Name
  • Type in the editor:
class A{};
var a = A{};

function f(a:A):A { A{} }
  • 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
  • Type in the editor:
class A{
    public var attr:String;
};

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

println(a.attr);
  • 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
  • Type in the editor:
class A{
    public var attr:A;
};

var a = A{ attr: A{} };
  • 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
  • Type in the editor:
class A{
    public var attr:A = A{};
};

var a = A{ attr: A{} };
  • 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
  • Type in the editor:
class A{}
class B extends A{}
  • Refactor->Rename the A class to D
    • Code should be compilable
    • The result should be
class D{}
class B extends D{}
  1. Mixin
  • Type in the editor:
class A{}
mixin class M{}
class B extends A, M{}
  • 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
  • Type in the editor:
var f = true;

while(f){
    f = not f;
}
  • 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
  • Type in the editor:
var s = [1,2,3,4,5];
var t = for(n in s) s[N] * indexof n;
  • 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