S
Shawn
Hi,
I have a huge class, which has about 30 class variables. And the class
has many methods. Each method doesn't need all the 30 class variables,
only need a subset of them. In another word, say the 30 class variables
can be grouped into 6 groups (say group A, group B, .., group F).
public class MyHugeClass
{
//group A class variables
private double a, b, c, d, e;
//group B class variables
private double w, t;
..
//group F class variables
private double t1, t2,t3;
public void method1() //only need group A and F variables, but it can
access all, unfortunately
{
...//code
}
public void method2() //only need group B and F variables, but it can
access all, unfortunately
{
...//code
}
...//more methods omitted
} //end of class
The method method1() only need group A and group F class variables,
doesn't need others. The method method2() only need group B and group F
class variables, doesn't need others. But since method1() and method2()
all below to the class, so they have access to all the class variables
(from group A to group F), which is more than they need and could
introduce errors. As you can imagine, this is a huge class. More
restrictions, better, because it could force the errors to be detected.
Thank you very much.
I have a huge class, which has about 30 class variables. And the class
has many methods. Each method doesn't need all the 30 class variables,
only need a subset of them. In another word, say the 30 class variables
can be grouped into 6 groups (say group A, group B, .., group F).
public class MyHugeClass
{
//group A class variables
private double a, b, c, d, e;
//group B class variables
private double w, t;
..
//group F class variables
private double t1, t2,t3;
public void method1() //only need group A and F variables, but it can
access all, unfortunately
{
...//code
}
public void method2() //only need group B and F variables, but it can
access all, unfortunately
{
...//code
}
...//more methods omitted
} //end of class
The method method1() only need group A and group F class variables,
doesn't need others. The method method2() only need group B and group F
class variables, doesn't need others. But since method1() and method2()
all below to the class, so they have access to all the class variables
(from group A to group F), which is more than they need and could
introduce errors. As you can imagine, this is a huge class. More
restrictions, better, because it could force the errors to be detected.
Thank you very much.