�� ������ ��ſ��� Replace
Constructor With Factory Method �����丵 ��ɿ� ���� �������� overview�� how
�� �����丵�� IntelliJ IDEA���� ���� �� �ִ°��� �����մϴ�.
Replace Constructor With Factory Method �������� ����� ����� ���� �� Ŭ������ �ν��Ͻ��� �����ϴ� ������ �޼ҵ���� �� ���� �����ڷ� ��ü�� �ʿ䰡 �ִ� ��쿡 �����մϴ�.
���� ���, ����� ������ �� Ŭ������ �����ϴ�:
public class Connection {
public Connection(String URL){
//some code here
}
}
public class ConnectionPool {
public Connection getConnection(String name){
Connection conn = new Connection(name);
}
//some code here
}
�����丵 ���� �ڵ�� �̷��� ���� ���Դϴ�:
private class Connection {
private Connection(String URL){
//some code here
}
public static Connection createConnection(String URL) {
return new Connection(URL);
}
}
public class ConnectionPool {
public Connection getConnection(String name){
Connection conn = Connection.createConnection(name);
}
//some code here
}
������ ���� ������ �޼ҵ� �ݷ� ��ü�˴ϴ�.
�����ڸ� ���丮 �޼ҵ�� ��ü
|
�����ڸ� ���丮 �޼ҵ�� ��ü�ϱ� ���ؼ�:
1. ����� �ν��Ͻ��� ���� �����Ǵ� Ŭ������ ���� �ʿ䰡 �ֽ��ϴ�.
2. ij���� ���丮 ���� ��ü�� ������ ������ �����ϰ� ���� �޴����� �Ǵ� �����Ϳ��� ������ ��ư�� Ŭ���ϴ� �Ϳ� ���� �ҷ����� �˾� �޴����� Refactor |
Replace Constructor With Factory Method...�� Ŭ���Ͻʽÿ�
3. ����� Replace Constructor With Factory Method ������������ ���� �� ���Դϴ�.

�̸�
|
���丮 �޼ҵ忡 ���� IDEA�� ���� ���ȵ� �ϳ��� �����ϰų� ��� �ڽ��� �̸��� �Է��Ͻʽÿ�.
|
In (fully qualified
name)
|
���丮 �޼ҵ尡 ��ġ�Ǵ� ����� �ڰ��� �־��� Ŭ���� �̸��� �Է��Ͻʽÿ�.
�� �ٸ� ����� �ʿ��� Ŭ������ ellipsis ��ư�� ������ �ҷ����� Choose Destination Class ���̾�α׿��� ã�� �� �Դϴ�.
|
����� �̸� ���� ���
|
üũ �ڽ��� �����ϸ� ��ſ��� � ����� �߰ߵǾ����� ��� ����ϰ� �ְ�, �׵��� ��ü�� �����ϵ��� ����մϴ�. �� üũ �ڽ��� ���õ��� ���� ��, IDEA�� ��ü�� �ڵ������� �����մϴ�.

|
������ üũ �ڽ��� Ȯ�ε��� �ʾ��� ����, ���� �߰ߵ� ����� � �б� ���� ���Ͽ��� �����ϸ� ��ſ��� ��� ��ü�� Ȯ���ϱ� ���� ������Ʈ �� �� �Դϴ�.
|
Refactoring Preview ���̾�α׿��� (���� �װ��� ��Ÿ����) ����� ����� ������ �м��� �� �ֽ��ϴ�. �����丵�� �Բ� �����ϱ� ���ؼ�, Do
Refactor�� Ŭ���մϴ�, �׷��� �ʴٸ� Cancel �� Ŭ���մϴ�. ���� ���� ������ Refactoring
Preview�� ���ʽÿ�.
|
|
�����丵�� ï¿½ï¿½ï¿½ï¿½ï¿½Ï¸é¼ ï¿½ï¿½ï¿½ï¿½ï¿½ ������ �˾ƾ� �մϴ�:
1. ���ο� ���丮 �޼ҵ�� �������� �Ͱ� �Ȱ��� ���ü��� ����ϴ�.
2. �����ڴ� ���丮 �޼ҵ�(���� ���, private ���� ������ �� Ŭ���� ���� ��ġ�Ѵٸ�)�� ���� �׼��� ������ �ּ��� ���ü��� �־����ϴ�.
3. �Ϻ� Ư���� �̽��� ���� Ŭ������ ���谡 �ֽ��ϴ�. ���丮 �޼ҵ�� �ܺ� Ŭ���� ���� �� �������� ������ �� �ֽ��ϴ�.
|