Posted By:
Thanks_forHelp
Posted On:
Thursday, July 26, 2007 12:37 PM
I need to get a list of objects of type B, based on the contents on an object of type A. So I coded classB as shown below. Is this considered proper/good/sound object oriented programming? Or is there a better, clearer way of doing that. public class ClassA { // constructor, getters and setters ... ... } public class ClassB { private ClassB() {} // private constructor public static List getClassB_Objects(ClassA objA) { List l = new ArrayList() // iterate through objA and compose few objB accordingly ClassB objB = new ClassB(); objB.setThis(objA.getThis()); objB.setThat(objA.getThat()); l.add(objB); // end iteratin
More>>
I need to get a list of objects of type B, based on the contents on an object of type A. So I coded classB as shown below. Is this considered proper/good/sound object oriented programming? Or is there a better, clearer way of doing that.
public class ClassA {
// constructor, getters and setters
...
...
}
public class ClassB {
private ClassB() {} // private constructor
public static List getClassB_Objects(ClassA objA) {
List l = new ArrayList()
// iterate through objA and compose few objB accordingly
ClassB objB = new ClassB();
objB.setThis(objA.getThis());
objB.setThat(objA.getThat());
l.add(objB);
// end iterating through objA.
//May loop through the code above few times.
}
return l;
}
This is how I use the code above
ClassA objA = new ClassA();
objA.setThis(...);
objA.setThat(...);
List myList = ClassB.getClassB_Objects(objA);
Any advice? Thanks in advance for your help.
<<Less