Skip to content

Commit

Permalink
hide empty fields & methods of class diagrams
Browse files Browse the repository at this point in the history
Signed-off-by: Manfred Hanke <manfred.hanke@tngtech.com>
  • Loading branch information
hankem authored and codecholeric committed Apr 10, 2024
1 parent 3489966 commit 8da60d5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
21 changes: 21 additions & 0 deletions docs/userguide/004_What_to_Check.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ classes().that().resideInAPackage("..foo..")

[plantuml, "class-naming-deps", svg, opts=interactive]
----
@startuml
hide empty members
skinparam componentStyle uml2
skinparam component {
Expand All @@ -69,6 +71,7 @@ note top on link #crimson: forbidden
Bar --> FooBar #green
note left on link #green: allowed
@enduml
----

[source,java]
Expand All @@ -81,6 +84,8 @@ classes().that().haveNameMatching(".*Bar")

[plantuml, "class-package-contain", svg, opts=interactive]
----
@startuml
hide empty members
skinparam componentStyle uml2
skinparam component {
Expand All @@ -103,6 +108,7 @@ package com.wrong {
note "resides in wrong package" as WrongPackage #crimson
FooController .. WrongPackage
@enduml
----

[source,java]
Expand All @@ -115,6 +121,8 @@ classes().that().haveSimpleNameStartingWith("Foo")

[plantuml, "inheritance-naming-check", svg, opts=interactive]
----
@startuml
hide empty members
skinparam componentStyle uml2
skinparam component {
Expand All @@ -137,6 +145,7 @@ FtpConnection --|> Connection #green
SshThing --|> Connection #crimson
note right on link #crimson: Has wrong name
@enduml
----

[source,java]
Expand All @@ -147,6 +156,8 @@ classes().that().implement(Connection.class)

[plantuml, "inheritance-access-check", svg, opts=interactive]
----
@startuml
hide empty members
skinparam componentStyle uml2
skinparam component {
Expand All @@ -173,6 +184,7 @@ ValidPersistenceUser --> EntityManager #green
IllegalPersistenceUser --> EntityManager #crimson
note right on link #crimson: Accessor resides in wrong package
@enduml
----

[source,java]
Expand All @@ -185,6 +197,8 @@ classes().that().areAssignableTo(EntityManager.class)

[plantuml, "inheritance-annotation-check", svg, opts=interactive]
----
@startuml
hide empty members
skinparam componentStyle uml2
skinparam component {
Expand All @@ -206,6 +220,7 @@ ValidPersistenceUser --> EntityManager #green
IllegalPersistenceUser --> EntityManager #crimson
note right on link #crimson: Accessor is not annotated with @Transactional
@enduml
----

[source,java]
Expand All @@ -218,6 +233,8 @@ classes().that().areAssignableTo(EntityManager.class)

[plantuml, "layer-check", svg, opts=interactive]
----
@startuml
hide empty members
skinparam componentStyle uml2
skinparam component {
Expand Down Expand Up @@ -253,6 +270,7 @@ note right on link #crimson: Access goes against layers
SomePersistenceManager -up--> SomeServiceOne #crimson
note right on link #crimson: Access goes against layers
@enduml
----

[source,java]
Expand All @@ -272,6 +290,8 @@ layeredArchitecture()

[plantuml, "cycle-check", svg, opts=interactive]
----
@startuml
hide empty members
skinparam componentStyle uml2
skinparam component {
Expand Down Expand Up @@ -301,6 +321,7 @@ ClassOneInModuleOne --> ClassTwoInModuleTwo #crimson
ClassOneInModuleTwo --> ClassOneInModuleThree #crimson
ClassTwoInModuleThree --> ClassOneInModuleOne #crimson
note right on link #crimson: Combination of accesses forms cycle
@enduml
----

[source,java]
Expand Down
16 changes: 12 additions & 4 deletions docs/userguide/006_The_Core_API.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ inheritance is not completely straight forward. Consider for example

[plantuml, "resolution-example", svg, opts=interactive]
----
@startuml
hide empty members
skinparam componentStyle uml2
skinparam component {
Expand All @@ -232,7 +234,7 @@ class SuperclassBeingAccessed {
SuperclassBeingAccessed <|-- ClassBeingAccessed
ClassAccessing o-- ClassBeingAccessed
@enduml
----

The bytecode will record a field access from `ClassAccessing.accessField()` to
Expand All @@ -246,6 +248,8 @@ The situation looks roughly like

[plantuml, "resolution-overview", svg, opts=interactive]
----
@startuml
hide empty members
skinparam componentStyle uml2
skinparam component {
Expand Down Expand Up @@ -276,6 +280,7 @@ MethodCallTarget "1" -- "0..*" JavaMethod : resolves to
JavaConstructorCall "1" *-- "1" ConstructorCallTarget : has
ConstructorCallTarget "1" -- "0..1" JavaConstructor : resolves to
@enduml
----

Two things might seem strange at the first look.
Expand All @@ -292,6 +297,8 @@ cases, for example:

[plantuml, "diamond-example", svg, opts=interactive]
----
@startuml
hide empty members
skinparam componentStyle uml2
skinparam component {
Expand All @@ -304,13 +311,13 @@ skinparam class {
BackgroundColor #white
}
class A <<interface>> {
interface A <<interface>> {
void targetMethod()
}
class B <<interface>> {
interface B <<interface>> {
void targetMethod()
}
class C <<abstract>> {
abstract class C <<abstract>> {
}
class D {
void callTargetMethod()
Expand All @@ -319,6 +326,7 @@ class D {
A <|-- C : implements
B <|-- C : implements
D -right- C : calls targetMethod()
@enduml
----

While this situation will always be resolved in a specified way for a real program,
Expand Down
3 changes: 3 additions & 0 deletions docs/userguide/008_The_Library_API.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ More precisely, the following holds:

[plantuml, "onion-architecture-check", svg, opts=interactive]
----
@startuml
hide empty members
skinparam componentStyle uml2
skinparam class {
Expand Down Expand Up @@ -112,6 +114,7 @@ note right on link #crimson: application services must not\nknow about any adapt
Cli --> RestController #crimson
note right on link #crimson: one adapter must not know\nabout any other adapter
@enduml
----


Expand Down

0 comments on commit 8da60d5

Please sign in to comment.