Simon B Simon B - 1 month ago 10
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:

project.page.login.LoginPage


And a class that represents an Account home page:

project.page.account.AccountHome


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.
project.page.chrome


project.page.chrome.BasePage
project.page.chrome.Menu
project.page.chrome.Footer
project.page.chrome.Header


or in the parent package:

project.page


e.g.

project.page.BasePage
project.page.chrome.Menu
etc


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

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.

Comments