No need to apologize, Mike ;).
On Aug 4, 5:08 pm, "Mike Nereson" <
mikenere...@gmail.com> wrote:
> One more time its me. There's another thing I've discovered. To me it> feels quite strange to define, what is forbidden instead of what is
> > allowed. The approach of defining violations generates a lot of false
> > positives if not defined correctly. I think it would be easier to do
> > not allow any dependency by default - generating false negatives - and
> > the step by step defining what is allowed and what not.
>
> I have two thoughts on why it is better to provide the negatives rather than
> the positives.
>
> First, is the java runtime. I don't think we want our users to have to
> define all of the or any of the java packages, such as java.lang, java.util
> etc.
This is why I gave the <commons> element a go. These dependencies are
automatically added to all rules and thus do not need to require
multiple definitions. Maybe one could simply call the element <ignore>
and do not regard these packages at all?!
> <module id="module1">
> <packages>
> <package>com.company.project.module1</package>
> <package>com.company.project.module1..*</package>
> </packages>
> <dependencies>
> <dependency>module2</dependency>
> </dependencies>
> <module>
>
> <module id="module2">
> <packages>
> <package>com.company.project.module2</package>
> <package>com.company.project.module2..*</package>
> <packages>
> <dependencies/>
> <module>
This is the way SonarJ builds its architecture model. I could imagine
this as a further step but the simple turnaround was much easier to
implement as a POC ;).
> If you have ..project.web, ..project.service, ..project.dao and you define
> your rules with wildcards, then adding a new package to one of these
> packages would be included in the rules.
I especially pay attention not to let single packages have
dependencies to many other packages. This leads to package structures
that have much less allowed dependencies, that forbidden. Imagine a
package having one allowed dependency but 20 not allowed. Playing
around with the POC I think the configuration amount has reduced
significantly.
The case of adding packages and breaking rules can be illustrated a
little better imagining the situation of adding an additional library.
Adding Hibernate to your project would require you to reconfigure all
your rules except the one describing the DAO layer not to allow to
acces hibernate. Doing this instead of simply declaring "Only DAO is
allowed to use Hibernate" seems weird to me.
I think i don't need to elaborate on this much more, as I think you
got my point. I hope to here opinions from other users as well ;).
Regards,
Ollie