0

I'm mapping out a piece of software using a class diagram, that I now want to separate into packages in a package diagram.

My problem is this: How do you represent connections between classes from two different packages?

For example, I have a class in my 'Database' package that connects to another class in my 'View' package. However if I separate them into two separate class diagrams (one for each package), that connection won't be represented. Is this okay?

PL200
  • 741
  • 6
  • 24
  • See examples from [uml-diagrams.org](http://www.uml-diagrams.org/package-diagrams-overview.html) – xmojmr Aug 16 '16 at 05:13

3 Answers3

0

Packages are just one way to group UML elements and they do primarily not imply relations between the elements themselves. To show relations between elements just connect them as appropriate irrelevant of where they are placed in packages. Of course, there should be more relations of elements inside a package than to those outside. Elements in a package indicate that they have a stronger relationship to each other than to elements outside.

You can show a package hierarchy on top to on package level.

When you create diagrams inside the package you can create different kinds: purely package internal, such with relations outside or a mix. This depends on what ever suits best.

qwerty_so
  • 35,448
  • 8
  • 62
  • 86
0

One good use of packages is in a domain chart that shows dependencies between different problem spaces. Each problem space is represented by a package. The packages are connected by dependency lines. This implies that each package exposes an interface to the packages that are related through the dependencies.

It sounds to me like you have a bit of domain pollution. Perhaps the database shouldn't know about the view. Perhaps there should be a controller that reads the database and updates the view. The class that accesses functionality within the package would access a package interface.

The benefit of this technique for system design is that this encapsulation and decoupling makes it easier to change the internals in one class without the change rippling through the system.

Bruce
  • 2,230
  • 18
  • 34
0

It's absolutely fine to present elements from various packages on one diagram. In such case you should remember that package creates a namespace and thus elements should be presented with a qualified name. Note if you create a class diagram for elements from package A you need to use qualified names only for elements from other packages (e.g. package B).

Ister
  • 5,958
  • 17
  • 26