oop - Is it bad practice to have a class that requires a reference to the instantiating object? -
I saw it in someone's code and Wow thought, this is a great way to solve this particular problem, but it Probably violates good oo theory in an epic way.
In the manufacturer for a set of all classes obtained from a common base class, they require references to the Instanting Class that passes them. For example, Foo Foo_i = new (this);
Then the Fu will call the methods in the instancing class to get information about other things contained by the installation class.
On one side, it simplifies a ton of code which model the 5-layer tree structure in the hardware (agents are plugged into ports on many switches, etc.). On the other hand, these objects are linked to each other to a large extent, which seems very wrong, but I do not have enough information about OO and D. on which I have to put my finger.
So, is it okay? Or is this oo equal to a goto statement?
I try and avoid this to avoid information if I know less information about a class Or it's easy to check and verify. It's being said, this leads to more elegant solutions in some cases, so if it is not doing then many of the parameters have to go through the inclusion of filled parameters, so in all ways Go. For example, with a lot of Java internal classes:
public class external {private square inner (public Inner ()} // // Members of external use are used for that example It immediately)}}
Comments
Post a Comment