�� ������ Use Interface Where
Possible �����丵�� ���� ��ſ��� �������� overview�� how
�� �����丵 ����� IntelliJ IDEA���� ���� �� �ִ°��� �����մϴ�.
Use Interface Where Possible �����丵 ����� ����ڿ��� ���̽� Ŭ����/�������̽����� ���� Ŭ���� �Ǵ� ���� �������̽��� �����ϴ� ���� Ŭ������ �ν��Ͻ��� �Ļ��� ���� �޼ҵ��� ������ �����ϴ� ���� ����մϴ�.
���� ���, ����� ���� Ŭ������ �����ϴ�:
public class ClassParent {
void method1(){
//some code here
}
void method2(){
//some code here
}
}
public class ClassChild extends ClassParent
{
void method1() {
super .method1();
}
void method2() {
super .method2();
}
}
public class UsageClass {
void myMethod(){
ClassChild classChild = new ClassChild();
classChild.method1();
classChild.method2();
}
}
ClassChild���� �����丵�� �����Ͻʽÿ�. UsageClass �� ������ ���� ����� ���Դϴ�:
public class UsageClass {
void myMethod(){
ClassParent classChild = new ClassChild();
classChild.method1();
classChild.method2();
}
}
�����ϸ� �������̽� ���
|
�����ϸ� �������̽� �Ǵ� ����Ŭ������ ����ϱ� ���ؼ�:
1. ������ �Ǵ� �޼ҵ尡 �θ� Ŭ���� �Ǵ� �������̽��� ���ӵ� ���� ( Project, Commander ) ���� �ϳ����� Ŭ���� ���� ij���� �����ϰ� ���� �޴�, �Ǵ� ������ ��ư�� Ŭ���Ͽ� �ҷ����� �˾� �޴����� Refactor |
Use Interface Where Possible�� Ŭ���Ͻʽÿ�.
2. ����� Use
Interface Where Possible ������������ �� ���Դϴ�.

Change Usages of <your_package_name>.<your_class_name>
to
|
����� ����� �ʿ䰡 �ִ� ������ �θ� Ŭ����/�������̽��� ������κ����� �����Ͻʽÿ�.
|
Use interface/superclass in instanceof
|
���� ���õǸ�, IDEA�� ���õ� ����Ŭ����/�������̽��� ���� instanceof ������Ʈ��Ʈ�� ���縦 ���� Ȯ���� ���̰�, ���� ���� �߰ߵǸ� �װ��� ������ ���Դϴ�.
���� ���, ����� ParentInterface �� �±� �������̽��� ������ �ڵ�(���� ������ �����Ͽ�)�� �����ϴ�:
public interface BaseInterface {
void myMethod();
}
public interface ParentInterface extends BaseInterface {
//some code here
}
public class ClassChild implements ParentInterface
{
public void myMethod(){
//some code here
}
}
public class UsageClass {
void myMethod(){
ClassChild child = new ClassChild();
child.myMethod();
if (child instanceof ParentInterface) {
//some code here
}
}
}
�׸��� �����丵 ���μ����� ParentInterface �� ����ǰ� �� �Ŀ� UsageClass �� ������ ���� �� ���Դϴ�:
public class UsageClass {
void myMethod(){
ClassChild child = new ClassChild();
child.myMethod();
if (child instanceof BaseInterface) {
//some code here
}
}
}
|
����� �̸� ���� ���
|
�� üũ �ڽ��� �����ϸ� ��ſ��� ����� �߰ߵ� ���� ������ ��� ��� ���� ����ϰ�, ��ſ��� �׵��� ��ü�� �����ϴ� ���� ����մϴ�.
�� üũ �ڽ��� ���õ��� ���� ��, IDEA�� ��ü ��ɸ� �ڵ������� �����մϴ�.

|
������ üũ �ڽ��� Ȯ�ε��� �ʾ��� ����, ���� �߰ߵ� ����� � �б� ���� ���Ͽ��� �����ϸ� ��ſ��� ��� ��ü�� Ȯ���ϱ� ���� ������Ʈ �� ���Դϴ�.
|
Refactoring Preview ���̾�α�(���� �װ��� ��Ÿ����)����, ����� ����� ������ �м��� �� �ֽ��ϴ�.
�����丵�� �Բ� �����ϱ� ���ؼ�, Do
Refactor Ŭ���Ͻʽÿ�, �׷��� �ʴٸ� Cancel �� Ŭ���Ͻʽÿ�. ���� ���� ���� Refactoring
Preview�� ���ʽÿ�.
|
|
�׸��� ���� � Ŭ����/�������̽� ��뵵 �θ� Ŭ����/�������̽��� ��ü�� �� ������, ��ſ��� ������ �޽����� ������Ʈ �� ���Դϴ�:

|