�� ������ Make Method Static �����丵 ������ overview�� �����ϰ� how �� �����丵�� IntelliJ
IDEA���� ���� �� �ִ°��� �����մϴ�.
Make Method Static �����丵�� �� �޼ҵ带 �ٸ� Ŭ������ �̵��ϴ�Move
Members �����丵�� ���� ������ �ܰ� �Ӹ��ƴ϶� Ŭ���� �ν��Ͻ��� �������� �ʰ� �� �޼ҵ带 ������ ������� ����� ���� �������� �޼ҵ带 ������ ������ ��ȯ�ϴµ� ���ȴ�. Ÿ�� �޼ҵ尡 �������� ����� �����丵 ����, �׸��� ��� ���� �ִٸ� Ŭ�����κ��� �ʿ��� �Ű� ������ �߰��� ���Դϴ�.
���� ���, ���� �ڵ尡 �����丵 ������ �ֽ��ϴ�. ����� �� ���� Ŭ������ �����ϴ�:
public class ConnectionPool{
HashMap mPool;
Connection getConnection(String name){
return (Connection) mPool.get(name);
}
}
public class Processor{
ConnectionPool myCP;
void detach(String name){
myCP.getConnection(name).abortConnection();
}
}
�׸��� �װ��� getConnection �޼ҵ带 �������� ����⿡ �����ϴ� . ����� ���ÿ� ����, �����丵�� ���� �� ���� ��� ���� �� ���� ���� ���� �� �ֽ��ϴ�:
���� ����� Ŭ���� �ν��Ͻ��� �����ϴ� �Ű� ������ �ʿ�� �ϸ�:
public class ConnectionPool{
HashMap mPool;
static Connection getConnection(ConnectionPool connectionPool, String name){
return (Connection) connectionPool.mPool.get(name);
}
}
public class Processor{
ConnectionPool myCP;
void detach(String name){
ConnectionPool.getConnection(myCP, name).abortConnection();
}
}
�Ǵ� ����� �Ű� �����μ� �� ������ �ʵ带 ����ϰ� �;��Ѵٸ�:
public class ConnectionPool{
HashMap mPool;
static Connection getConnection(HashMap mPool1, String name){
return (Connection) mPool1.get(name);
}
}
public class Processor{
ConnectionPool myCP;
void detach(String name){
ConnectionPool.getConnection(myCP.mPool, name).abortConnection();
}
}
�޼ҵ带 �������� �����
|
�޼ҵ带 �������� ����� ����, ù ��°�� ij���� ���� ���� ������ �Ǵ� ����� �������� �DZ⸦ ���ϴ� �޼ҵ��� ���� �����Ͻʽÿ�.

���� �޴����� �Ǵ� �����Ϳ��� ������ ��ư�� Ŭ���ϴ� �Ϳ� ���� �ҷ����� �˾� �޴����� Refactor
| Make
Method Static... �� Ŭ���Ͻʽÿ�.
���� �޼ҵ尡 � Ŭ���� ���� ��Ҹ� ����ϸ� ������ Introduce Parameter ���̾�αװ� ��Ÿ���ϴ�:

���̾�α״� ������ ��� �����ϴ�:
�̸��� �ִ� �Ű� �����μ��� ��ü �߰�
|
���� üũ�ϸ�, �޼ҵ� ����� �ݷ� �Ű� �����μ��� Ŭ���� �ν��Ͻ��� �߰��մϴ�.

|
���� Ÿ�� �޼ҵ尡 �� Ŭ������ �� ������ �޼ҵ带 ����ϸ� �� üũ �ڽ��� �ڵ������� ���õ˴ϴ�.
���� ����� �׷� �� ������ �޼ҵ带 ���� üũ �ڽ��� �����ϸ� Problems
Detected ���̾�α׿� �Բ� ��� �ް� �� �� �Դϴ�. ���� ����� �װ��� �����ϰ� Continue�� ������ �����丵�� ����� ���̳� ��� �ڵ�� �������� �ȵ����� �𸨴ϴ�.
|
|
�ʵ忡 ���� �Ű� ���� �߰�
|
���� üũ�ϸ� �޼ҵ忡 ���� ���Ǵ� �ʵ��� ����� ��� �����ϰ� �մϴ�.
��Ͽ��� ����� �޼ҵ忡 �Ű� �����μ� �Ѿ�� �� ������ �ʵ带 �޼ҵ� ����/�ݿ��� �ʵ��� ������ �����ϴ� Move Up / Move
down ��ư�� ����Ͽ� �����ϰų�/�������� ���� �� �ֽ��ϴ�.

|
���� Ÿ�� �޼ҵ尡 �� Ŭ������ �� ������ �ʵ带 ����ϸ� �� üũ �ڽ��� �ڵ������� ���õ˴ϴ�.
���� ����� �׷� �� ������ �ʵ带 ���� üũ �ڽ��� �����ϸ� �����丵�� ����� ���̳� ��� �ڵ�� �������� �ȵ����� �𸨴ϴ�.
|

|
���� ����� Ÿ�� �޼ҵ忡 ���� ����ϴ� �� ������ �ʵ带 ���� �����ϸ� Problems
Detected ���̾�α׿� �Բ� ��� �ް� �� �� �Դϴ�. ���� ����� �װ��� �����ϰ� Continue�� ������ �����丵�� ����� ���̳� ��� �ڵ�� �������� �ȵ����� �𸨴ϴ�.
|
|
����� �̸� ���� ���
|
�� üũ �ڽ��� �����ϸ� ����� � ����� �߰ߵǾ����� �����ϰ�, �׵��� ��ü�� �����ϵ��� ����մϴ�.
�� üũ �ڽ��� ���õ��� ���� ��, IDEA�� ��ü�� �ڵ������� �����մϴ�.

|
������ üũ �ڽ��� ���õ��� �ʾ��� ����, ���� �߰ߵ� ����� � �б� ���� ���Ͽ��� �����ϸ� ����� ��� ��ü�� Ȯ���ϴ� ������Ʈ�� ��ſ� ���� �� �Դϴ�.
|
|
|
���� Ŭ���� ���� ����� ��� �͵� Ÿ�� �޼ҵ忡 ���� ������ ������, Make
Method Static �� ������ ���� ���� ���Դϴ�:

�װ��� �� üũ �ڽ��� �����ϴ�:
Replace usage qualifiers
with class references
|
���� üũ�Ǹ�, Ŭ���� �̸��� �Բ� Ŭ���� ��� ���ľ ��ü�մϴ�.
|
Preview usages to
be changed
|
���� ���ʽÿ�.
|
|
Make Method Static �����丵�� �����ϸ� ����� ������ ���ۿ��� �˰� �־�߸� �մϴ�. ���� ���μ��� Ŭ����������� ����� ������ �ڵ带 �����ϴ�:
public class Processor{
void detach(String name){
ArrayList connectionPools = new ArrayList();
for (Iterator iterator = connectionPools.iterator(); iterator.hasNext();) {
((ConnectionPool) iterator.next()).getConnection(name).abortConnection();
}
}
}
�����丵 �Ŀ� �ڵ尡 �ֽ��ϴ�:
public class Processor{
void detach(String name){
ArrayList connectionPools = new ArrayList();
for (Iterator iterator = connectionPools.iterator(); iterator.hasNext();) {
ConnectionPool.getConnection(((ConnectionPool) iterator.next()).aInt,
((ConnectionPool) iterator.next()).mPool, name).abortConnection();
}
}
}
����� �� �� �ִ� �Ϳ� ����, iterator �� ������ �߸��� �ʵ��� ������ ���� �� ��� �þ�ϴ�. �׷���, IDEA�� ����/����/���� �������μ��� �׷� ��츦 �ӽ� ������ ����ϰ� new Ű���带 ����Ͽ� ���������� ������ �ذ��� �� �ֽ��ϴ�.
���� ���:
public class Processor{
void detach(String name){
new ConnectionPool().getConnection(name).abortConnection();
}
}
�׸��� ���⿡ �����丵 ���� �ڵ尡 �ֽ��ϴ�.
public class Processor{
void detach(String name){
final ConnectionPool connectionPool = new ConnectionPool();
ConnectionPool.getConnection(connectionPool.aInt, connectionPool.mPool, name).abortConnection();
}
}
�ӽ� ������ �� ������ �ʵ忡 ���� ConnectionPool Ŭ������ �� ���� �ٸ� �ν��Ͻ��� ������ ���ϱ� ���� �����˴ϴ�
|