Hi Deepak,
Originally posted by Deepak Arora:
[..]on re-reading the para I deduce that
1)package dependencies are simmilar to compilation dependencies
2)with packages dependencies are not transitive &
3)compilation dependencies are transitive.
You have correctly mentioned 2) and 3).Compilation dependencies are transitive in nature;Package dependencies are not.Hence, package dependencies cannot be similar to compilation dependencies.So 1) is incorrect.
I believe, Fowler mentions somewhere in that chapter that in case of Package dependencies, there is a sort of "shielding" that takes place to avoid transitive dependencies.If this shielding would not have taken place we could have said both package and compilation dependencies are similar.
As regards Generalization, the subtype should conform to the type defined by the supertype.This according to specification perspective, defines the responsibility of the subtype.This goes with packages as well.So if you have a superpackage and a subpackage linked by Generalization, the subpackage has to conform to the responsibities inherited from the superpackage.
Generalization by default means a dependency from a subtype to a supertype.As Fowler puts it, this is a good way to reduce the overall dependency, since there is no dependency from supertype to subtype.This is because, until runtime the superclass doesnot know the instance of the subclass it is refering to.
Just remember, that you can never eliminate a dependency totally; you can only reduce it.So in the above case, while dependency from subtype to supertype is acceptable, the dependency from supertype to subtype is not desired.
Given a situation(case),
you should consider packaging highly specialized classes together.This means classes which are highly coupled/associated comes in the same package.You may then subclass/subpackage classes, which you believe would have a generalization relationship with the superclass/superpackage you just created.This actually means subpackage classes are bound to have some visibility/dependency to superpackage classes because of generalization.
Hope this helps,
Sandeep
[This message has been edited by Desai Sandeep (edited July 11, 2001).]