I am relatively new to the design pattern, and it seems to me that the design pattern is most difficult part and the top level to the whole software design (please correct me if I am wrong).
I have a big class now with several embeded functionalities, and I want to refactor some functionalities into subclasses. But most of these subclasses will use the output from its preceding code output as constructor input. This makes me confused. How should I implement this situation into my design pattern? Or should I avoid this dependency situation?
The following is an example of my class:
public class Edit
{
private List<Graphic> _listGraphic;
public Initialization()
{
_listGraphic= SomeFunctionHere();
BatchEdit batchEdit= new BatchEdit(_listGraphic);
}
}
public class BatchEdit
{
public BatchEdit(List<Graphic> listGra)
{
}
}
Thanks,
Wei
Looks to me as if you want to delegate some behaviour to other classes, which are usually not “subclasses” (in terms of inheritance).
A delegate may depend on it’s caller – you may pass a reference to the caller to the constructor, if the delegate needs use some of it’s callers.
Please do not confuse “design” with “design pattern”. You develop a design for your application that should be build upon common design patterns. Design patterns guide to solutions for most common problems.