Class inside Class or not?
in
Programming Questions
•
1 year ago
Let's say you have an objectA defined by ClassA, containing an objectB defined by ClassB;
You can have two separate Class(es) like that:
- ClassA object A = new ClassA();
- class ClassA{
- ClassB objectB = new ClassB();
- ClassA(){}
- }
- class ClassB{
- ClassB(){}
- }
or a Class containing the other one like this:
- ClassA object A = new ClassA();
- class ClassA{
- ClassB objectB = new ClassB();
- ClassA(){}
- class ClassB{
- ClassB(){}
- }
- }
Discussing performance and architecture, is one is better than the other? and why?
Thanks
1