�� ������ Introduce Field �����丵 ������ ��ſ��� �������� overview�� �����ϰ� how ��
�����丵�� IntelliJ
IDEA���� ���� �� �ִ°��� �����մϴ�.
Introduce Field �����丵�� ���ο� �ʵ带 �����ϰ�, ���õ� ǥ���İ� �Բ� �װ��� �ʱ�È�մϴ�. ���� ǥ������ �ʵ��� ������� ��ü�˴ϴ�.
���� ���, �����丵 ���� �Ϻ� �ڵ尡 ���⿡ �ֽ��ϴ�:
public class MyApplet extends JApplet {
public void init() {
Container cp = getContentPane();
cp.setLayout( new FlowLayout());
cp.add( new Button("Button"));
}
}
�츮�� Introduce Field �����丵�� �����ϱ� ���� ���ο� ��ư ("Button") �� �����մϴ� .
���� �츮�� ������ �ڵ带 �����ϴ�:
public class MyApplet extends JApplet {
private JButton button = new JButton("Button");
public void init() {
Container cp = getContentPane();
cp.setLayout(new FlowLayout());
cp.add(button);
}
}
�ʵ� �����ϱ�
|
�ʵ带 �����ϱ� ����, �����Ϳ��� ���ο� �ʵ忡 �Ҵ�� ǥ������ �����Ͻʽÿ�.


|
Introduce Field �����丵�� ���� ǥ������ �����ϱ� ���� Ctrl +
W (�ܾ� ����)�� ����ϴ� ���� ���� �����մϴ�.
�ڵ��� ���� Ȯ���� �����ϰ� ����� ij���� ������ ��� ���� ��ġ�ϰ�, Ctrl + W�� �� �� ������ � ǥ�����̶� ���� �ڵ忡�� �����ص� �����ϴ�:
|
�� �޴����� �Ǵ� �����Ϳ��� ������ ��ư�� Ŭ���Ͽ� �ҷ����� �˾� �޴����� Refactor | Introduce
Field... �׸��� Ŭ�� �Ͻʽÿ�.
������ Introduce Field ���̾�αװ� ��Ÿ���ϴ�:

Introduce Field ���̾�α��� �ֻ�������, ���� �ʵ��� Ÿ���� ǥ�õ˴ϴ�.
Name �ؽ�Ʈ �ʵ忡�� ����� �ʵ忡 �̸��� �Է½�ų �� �ְų�, IDEA�� ���� ���ȵ� �ϳ��� ����� �� �ֽ��ϴ�. Ư�� ���ȵ� �̸��� �� Ÿ�� ������ ���õ� ǥ���Ŀ� �����մϴ�.
���� ����� �ڵ� ��Ÿ�� �ɼ� ���� �ʵ带 ���� �̸� �ĺ� ��ȣ�� �����ߴ���� ���ȵ� �ʵ� �̸��� �����ϴ� ���� IDEA�� ���� ���� ���Դϴ�.

|
���� ���õ� ǥ������ ���� �߻��� ������, �׵� ��δ� �����Ϳ��� ������ ���Դϴ�. �׸��� Replace all occurrences of expression ( <number
of occurrences found> ) üũ�ڽ��� ���̾�α� �������� �ٴڿ��� ��Ÿ�� �� �Դϴ�. ���� üũ�ڽ��� ���õǸ�, ���õ� ǥ������ ��� �߻��� ��ü�� �� �Դϴ�. �׷��� ������ ������ ����� ó���� ������ ǥ���ĸ��� ����� �� �Դϴ�.
|
���̾�α״� 3���� �ɼ� �׷��� �����ϴ�:
�ʱ�È
|
�ʵ尡 �ʱ�È�� ���� �����մϴ�:
Current
method - �ʵ�� ���õ� ǥ���Ŀ� �ռ� �޼ҵ� ������ ��� �ʱ�È�˴ϴ�.
Field
declaration - �ʵ�� �ٸ� �ʵ�� �Բ� �ʱ�È�˴ϴ�.
Class
constructor - �ʵ�� Ŭ���� �����ڿ��� �ʱ�È�˴ϴ�.
|
���ü�
|
�ʵ带 ���� ���ü� ������ �����մϴ�:
Private
Package
local
Protected
Public
|
�ٸ� ������
|
�ʵ带 ���� �������� �����մϴ�:
Final

|
���� �ʵ尡 ������ �޼ҵ�� �ʱ�È�Ǹ� final üũ �ڽ��� �Ұ����ϰ� �ϰ� �˴ϴ�.
|
|
|
���� ���õ� �ڵ尡 ��ȿ�� ǥ������ ǥ������ ������ ��ſ��� ������ ���� �޽����� ������Ʈ �� ���Դϴ�:

|