Utility/Helper and factory classes are still frequently used in core Java. For instance, java.util.Collections, java.nio.file.Files are utility classes, java.nio.files.FileSystems and java.nio.files.Paths are factory classes with static factory methods.
My question is how to make use of UML class diagram to express the relationship between these factory or utility/helper classes and those objects they can generate?
If a class uses another class they connect with a dashed line arrow. By saying uses it means that class A has declared class B inside a method, as parameter or calls it statically.
class A {
public void test(B b) {
}
}
or
class A {
public void test() {
B b = ...
}
}
or
class A {
public void test() {
B.teststaticmethod();
}
}
If a class depends on another class they connect with a line arrow. By saying depends it means that class A has class B as private member inside.
class A {
private B b;
}
With this knowledge you can model it yourself.
There are lots of examples for the factory pattern, like in uml-diagrams.org
Helper classes would just use dependencies to the multiplicity of classes they reference.

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With