Simon B Simon B - 1 year ago 70
Java Question

rule of thumb relating to access of classes from sibling packages

Is there are any rule of thumb that relates to whether your package structure should allow access of a class from another class in a sibling package.

An example I have a class that represents a Login page:

And a class that represents an Account home page:

Both pages access the std chrome for the project (Header, Footer, Menu stuff and BasePage), is it better to put thoses classes in a sibling package e.g.

or in the parent package:


I know that this is a stylistic rule of thumb question, which in a way is subjective.

What I wish to know is if there is a commonly accepted rule for this sort of thing. And if so what is the reasoning behind what are the problems or benefits associated with each approach.

Further to Vampire's answer.
My question is not whether you can reference classes from one sibling package to another. It's whether you should and what are the reasons (either way).

Answer Source

There are maybe not exact rules but some guidelines. Link to answer to another similar question Since this answer appears on SO, pasting only the link here. Reading the Uncle Bob articles may give you some pointers.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download