Reporter | Hadi Hariri (hadihariri) |
---|---|
Created | Feb 18, 2010 8:49:53 PM |
Updated | Jan 24, 2012 8:21:14 PM |
Priority | Normal |
Type | Feature |
Fix versions | Mirabile Futurum |
State | Open |
Assignee | Sergey Shkredov (serjic.shkredov) |
Subsystem | No subsystem |
Affected versions | No Affected versions |
Fixed in build | No Fixed in build |
From Customer Philip Laureano.
One of the things that me and a few other developers would love to see in R# version >=5.0 is the ability to extract entire classes from an existing class. For example, let's say I have a class named OneBigClass with two sets of logically related methods:
public class OneBigClass
{
private object _field1;
private object _field2;
public void DomainMethod1()
{
_field1 = 12345;
}
public void DomainMethod2()
{
_field1 = 54321;
}
public void SomeOtherDomainMethod1()
{
_field2 = 12345;
}
public void SomeOtherDomainMethod2()
{
_field2 = 54321;
}
}
Ideally, what I would like R# to do is be able to let me choose which methods to extract into a separate class. For this example, let's assume that I wanted to extract methods DomainMethod1 and DomainMethod2. This is what the output should look like:
public class OneSmallerClass
{
private object _field1;
public void DomainMethod1()
{
_field1 = 12345;
}
public void DomainMethod2()
{
_field1 = 54321;
}
}
The OneBigClass class should now look like this:
public class OneBigClass
{
private object _field1;
private OneSmallerClass _smallClass = new OneSmallerClass();
public void DomainMethod1()
{
_field1 = 12345;
}
public void DomainMethod2()
{
_field1 = 54321;
}
public void SomeOtherDomainMethod1()
{
_smallClass.SomeOtherDomainMethod1();
}
public void SomeOtherDomainMethod2()
{
_smallClass.SomeOtherDomainMethod1();
}
}
Extract method is a good tool, but having to manually extract large classes can be quite tedious with the large codebases. Is there any way that you can pass this off to the Jetbrains R# devs? Thanks a lot, dude!
Note by Hadi: If something like this were to be added, I'd give the option to inject the dependency instead of creating new instance.
One of the things that me and a few other developers would love to see in R# version >=5.0 is the ability to extract entire classes from an existing class. For example, let's say I have a class named OneBigClass with two sets of logically related methods:
public class OneBigClass
{
private object _field1;
private object _field2;
public void DomainMethod1()
{
_field1 = 12345;
}
public void DomainMethod2()
{
_field1 = 54321;
}
public void SomeOtherDomainMethod1()
{
_field2 = 12345;
}
public void SomeOtherDomainMethod2()
{
_field2 = 54321;
}
}
Ideally, what I would like R# to do is be able to let me choose which methods to extract into a separate class. For this example, let's assume that I wanted to extract methods DomainMethod1 and DomainMethod2. This is what the output should look like:
public class OneSmallerClass
{
private object _field1;
public void DomainMethod1()
{
_field1 = 12345;
}
public void DomainMethod2()
{
_field1 = 54321;
}
}
The OneBigClass class should now look like this:
public class OneBigClass
{
private object _field1;
private OneSmallerClass _smallClass = new OneSmallerClass();
public void DomainMethod1()
{
_field1 = 12345;
}
public void DomainMethod2()
{
_field1 = 54321;
}
public void SomeOtherDomainMethod1()
{
_smallClass.SomeOtherDomainMethod1();
}
public void SomeOtherDomainMethod2()
{
_smallClass.SomeOtherDomainMethod1();
}
}
Extract method is a good tool, but having to manually extract large classes can be quite tedious with the large codebases. Is there any way that you can pass this off to the Jetbrains R# devs? Thanks a lot, dude!
Note by Hadi: If something like this were to be added, I'd give the option to inject the dependency instead of creating new instance.