By S.Luann
Dependency between classes could be strong or weak. If a class just has a reference to another class without accessing it's members, it is a weak dependency, because changes in the referenced class won't affect the referencing class code. In contrast, if a class has reference to another class and access it's members, the relation ship is strong dependency.
In my idea, strong dependency can be noted with sold line and an arrow, while a weak dependency uses dash line with an arrow.
I found this issue when implementing proxy design pattern.
class Client
{
void CallMethod()
{
private ISubject proxy = new Proxy();
proxy.doAction();
}
}
interface ISubject
{
void DoAction();
}
class Proxy : ISubject
{
public void DoAction()
{
// implementation
}
}
class Proxee
{
public void DoAction()
{
// implementation
}
}
In above code, class Client has dependency to ISubject and Proxy, but the dependency to Proxy is weak dependency while to ISubject is strong.
No comments:
Post a Comment